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
2
2
class Channel
3
3
def self . select ( *channels )
4
4
probe = Probe . new
5
-
6
5
channels . each { |channel | channel . select ( probe ) }
7
- probe . value
6
+ result = probe . value
7
+ channels . each { |channel | channel . remove_probe ( probe ) }
8
+ result
8
9
end
9
10
end
10
11
end
Original file line number Diff line number Diff line change @@ -16,6 +16,19 @@ module Concurrent
16
16
17
17
value . should eq 77
18
18
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
19
32
end
20
33
21
34
end
You can’t perform that action at this time.
0 commit comments