Skip to content

Commit fee0b7f

Browse files
committed
Fix: requiring concur makes Future available in the namespace
1 parent c79157d commit fee0b7f

File tree

14 files changed

+687
-686
lines changed

14 files changed

+687
-686
lines changed

examples/event_batching.cr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require "../src/concur"
2-
include Concur
32

43
record KeyboardEvent, id : Int32, key : Char
54
record MouseEvent, id : Int32, pos : {Int32, Int32}

examples/parallel_processing.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ pp Concur.source(Random.new) { |gen| {gen, {gen.rand, gen.rand}} }
1313
.select { |estimates|
1414
estimates.all? { |(i, e)|
1515
(e - Math::PI).abs / Math::PI < 1e-5
16-
}
16+
}
1717
}.flat_map { |estimates| estimates.map(&.first) }
1818
.take 1

examples/shard.lock

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ shards:
88
git: https://github.com/maiha/crt.cr.git
99
version: 0.4.0
1010

11-
dataclass:
12-
git: https://github.com/lbarasti/dataclass.git
13-
version: 1.1.1
14-
1511
rate_limiter:
1612
git: https://github.com/lbarasti/rate_limiter.git
1713
version: 1.0.1
1814

1915
tablo:
2016
git: https://github.com/hutou/tablo.git
21-
version: 0.9.5
17+
version: 0.10.1
2218

examples/shard.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ version: 0.1.0
44
authors:
55
- lbarasti <[email protected]>
66

7-
dependencies:
8-
dataclass:
9-
github: lbarasti/dataclass
7+
dependencies:
108
agent:
119
github: lbarasti/agent
1210
rate_limiter:

examples/url_checker.cr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
require "yaml"
22
require "http/client"
33
require "../src/concur"
4-
require "dataclass"
54
require "agent"
65
require "crt"
76
require "tablo"
87
extend Concur
98

10-
dataclass StatsCount{success : Hash(String, Int32), failure : Hash(String, Int32)}
9+
record StatsCount, success : Hash(String, Int32), failure : Hash(String, Int32)
1110

1211
class Stats
1312
@success : Agent(Hash(String, Int32))

examples/using_futures.cr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "../src/concur"
2+
3+
n = Future.new { 42 }
4+
.map { |v| v // 2 }
5+
.await!
6+
7+
pp n
8+
9+
raise Exception.new("Something went wrong") unless n == 21

shard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: concur
2-
version: 1.0.1
2+
version: 1.0.2
33

44
authors:
55
- lbarasti <[email protected]>

spec/future_spec.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe Future do
4747
it "can be awaited on with timeout" do
4848
f = Future.new { sleep 0.6; 42 }
4949
f.await(0.2.seconds)
50-
.should be_a Concur::Timeout
50+
.should be_a Future::Timeout
5151
f.await
5252
.should eq 42
5353
f.await(0.1.seconds)
@@ -56,7 +56,7 @@ describe Future do
5656

5757
it "can be awaited on with timeout and raise on exception" do
5858
f = Future.new { sleep 0.4; raise CustomError.new("error"); 42 }
59-
expect_raises(Concur::Timeout) {
59+
expect_raises(Future::Timeout) {
6060
f.await!(0.2.seconds)
6161
}
6262
expect_raises(CustomError) {
@@ -124,11 +124,11 @@ describe Future do
124124
results << ex.as(CustomError)
125125
raise Exception.new("runtime exception")
126126
}.on_error { |ex|
127-
results << Timeout.new
127+
results << Future::Timeout.new
128128
}.await.should be_a CustomError
129129

130130
results.first.should be_a CustomError
131-
results.last.should be_a Timeout
131+
results.last.should be_a Future::Timeout
132132
end
133133

134134
it "will not run #on_error callbacks if the future succeeds" do
@@ -172,7 +172,7 @@ end
172172
g = f.select { |x| x % 2 == 1 }
173173
h = f.select { |x| x % 2 == 0 }
174174
g.await.should eq 5
175-
h.await.should be_a Concur::EmptyError
175+
h.await.should be_a Future::EmptyError
176176
end
177177

178178
it "supports combining two futures with #flat_map" do

spec/readme_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe "Future example" do
1010
f.map { |v| v.downcase }
1111
.select { |v| v.size < 3 }
1212
.recover { |ex| ex.message || ex.class.to_s }
13-
.await.should eq "Concur::EmptyError"
13+
.await.should eq "Future::EmptyError"
1414
end
1515

1616
it "showcases #zip and #flat_map" do

0 commit comments

Comments
 (0)