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
3636 # Blocks on the barrier until the number of waiting threads is equal to `parties` or until `timeout` is reached or `reset` is called
3737 # If a block has been passed to the constructor, it will be executed once by the last arrived thread before releasing the others
3838 # @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
4040 def wait ( timeout = nil )
4141 @mutex . synchronize do
4242
@@ -60,7 +60,7 @@ def wait(timeout = nil)
6060 end
6161
6262 if remaining . woken_up?
63- return true
63+ return generation . status == :fulfilled
6464 else
6565 generation . status = :broken
6666 @condition . broadcast
Original file line number Diff line number Diff line change @@ -120,6 +120,15 @@ module Concurrent
120120 parties . times { Thread . new { barrier . wait ; latch . count_down } }
121121 latch . wait ( 0.1 ) . should be_true
122122 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
123132 end
124133
125134 context 'with timeout' do
You can’t perform that action at this time.
0 commit comments