File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ module Concurrent
5
5
describe BufferedChannel do
6
6
7
7
let ( :size ) { 2 }
8
- let ( :channel ) { BufferedChannel . new ( size ) }
8
+ let! ( :channel ) { BufferedChannel . new ( size ) }
9
9
let ( :probe ) { Probe . new }
10
10
11
11
context 'without timeout' do
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ module Concurrent
4
4
5
5
describe UnbufferedChannel do
6
6
7
- let ( :channel ) { subject }
7
+ let! ( :channel ) { subject }
8
8
let ( :probe ) { Probe . new }
9
9
10
10
context 'with one thread' do
@@ -37,9 +37,9 @@ module Concurrent
37
37
result = nil
38
38
39
39
Thread . new { channel . push 42 }
40
- Thread . new { result = channel . pop }
40
+ Thread . new { result = channel . pop ; }
41
41
42
- sleep ( 0.05 )
42
+ sleep ( 0.1 )
43
43
44
44
result . should eq 42
45
45
end
@@ -51,10 +51,21 @@ module Concurrent
51
51
Thread . new { result << channel . pop }
52
52
Thread . new { result << channel . pop }
53
53
54
- sleep ( 0.05 )
54
+ sleep ( 0.1 )
55
55
56
56
result . should have ( 1 ) . items
57
57
end
58
+
59
+ it 'gets the pushed value when ready' do
60
+ result = nil
61
+
62
+ Thread . new { result = channel . pop ; }
63
+ Thread . new { channel . push 57 }
64
+
65
+ sleep ( 0.1 )
66
+
67
+ result . should eq 57
68
+ end
58
69
end
59
70
60
71
describe 'select' do
You can’t perform that action at this time.
0 commit comments