File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def number_waiting
36
36
# Blocks on the barrier until the number of waiting threads is equal to `parties` or until `timeout` is reached or `reset` is called
37
37
# If a block has been passed to the constructor, it will be executed once by the last arrived thread before releasing the others
38
38
# @param [Fixnum] timeout the number of seconds to wait for the counter or `nil` to block indefinitely
39
- # @return [Boolean] `true` if the `count` reaches zero else false on `timeout` or on `reset` or on broken event
39
+ # @return [Boolean] `true` if the `count` reaches zero else false on `timeout` or on `reset` or if the barrier is broken
40
40
def wait ( timeout = nil )
41
41
@mutex . synchronize do
42
42
@@ -60,7 +60,7 @@ def wait(timeout = nil)
60
60
end
61
61
62
62
if remaining . woken_up?
63
- return true
63
+ return generation . status == :fulfilled
64
64
else
65
65
generation . status = :broken
66
66
@condition . broadcast
Original file line number Diff line number Diff line change @@ -120,6 +120,15 @@ module Concurrent
120
120
parties . times { Thread . new { barrier . wait ; latch . count_down } }
121
121
latch . wait ( 0.1 ) . should be_true
122
122
end
123
+
124
+ it 'return false if barrier has been reset' do
125
+ latch = CountDownLatch . new ( 1 )
126
+
127
+ Thread . new { latch . count_down if barrier . wait == false }
128
+ sleep ( 0.1 )
129
+ barrier . reset
130
+ latch . wait ( 0.1 ) . should be_true
131
+ end
123
132
end
124
133
125
134
context 'with timeout' do
You can’t perform that action at this time.
0 commit comments