File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ module Concurrent
22 class Channel
33 def self . select ( *channels )
44 probe = Probe . new
5-
65 channels . each { |channel | channel . select ( probe ) }
7- probe . value
6+ result = probe . value
7+ channels . each { |channel | channel . remove_probe ( probe ) }
8+ result
89 end
910 end
1011end
Original file line number Diff line number Diff line change @@ -16,6 +16,19 @@ module Concurrent
1616
1717 value . should eq 77
1818 end
19+
20+ it 'cleans up' do
21+ channels = [ UnbufferedChannel . new , UnbufferedChannel . new ]
22+ channels . each { |ch | ch . stub ( :remove_probe ) . with ( an_instance_of ( Probe ) ) }
23+
24+ Thread . new { channels [ 1 ] . push 77 }
25+
26+ value = Channel . select ( *channels )
27+
28+ value . should eq 77
29+
30+ channels . each { |ch | expect ( ch ) . to have_received ( :remove_probe ) . with ( an_instance_of ( Probe ) ) }
31+ end
1932 end
2033
2134 end
You can’t perform that action at this time.
0 commit comments