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
55 describe BufferedChannel do
66
77 let ( :size ) { 2 }
8- let ( :channel ) { BufferedChannel . new ( size ) }
8+ let! ( :channel ) { BufferedChannel . new ( size ) }
99 let ( :probe ) { Probe . new }
1010
1111 context 'without timeout' do
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ module Concurrent
44
55 describe UnbufferedChannel do
66
7- let ( :channel ) { subject }
7+ let! ( :channel ) { subject }
88 let ( :probe ) { Probe . new }
99
1010 context 'with one thread' do
@@ -37,9 +37,9 @@ module Concurrent
3737 result = nil
3838
3939 Thread . new { channel . push 42 }
40- Thread . new { result = channel . pop }
40+ Thread . new { result = channel . pop ; }
4141
42- sleep ( 0.05 )
42+ sleep ( 0.1 )
4343
4444 result . should eq 42
4545 end
@@ -51,10 +51,21 @@ module Concurrent
5151 Thread . new { result << channel . pop }
5252 Thread . new { result << channel . pop }
5353
54- sleep ( 0.05 )
54+ sleep ( 0.1 )
5555
5656 result . should have ( 1 ) . items
5757 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
5869 end
5970
6071 describe 'select' do
You can’t perform that action at this time.
0 commit comments