class Concurrent::MutexCountDownLatch
@!macro count_down_latch @!visibility private @!macro internal_implementation_note
Public Class Methods
new(count = 1)
click to toggle source
@!macro count_down_latch_method_initialize
Calls superclass method
# File lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb, line 12 def initialize(count = 1) Utility::NativeInteger.ensure_integer_and_bounds count Utility::NativeInteger.ensure_positive count super() synchronize { ns_initialize count } end
Public Instance Methods
count()
click to toggle source
@!macro count_down_latch_method_count
# File lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb, line 34 def count synchronize { @count } end
count_down()
click to toggle source
@!macro count_down_latch_method_count_down
# File lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb, line 26 def count_down synchronize do @count -= 1 if @count > 0 ns_broadcast if @count == 0 end end
wait(timeout = nil)
click to toggle source
@!macro count_down_latch_method_wait
# File lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb, line 21 def wait(timeout = nil) synchronize { ns_wait_until(timeout) { @count == 0 } } end
Protected Instance Methods
ns_initialize(count)
click to toggle source
# File lib/concurrent-ruby/concurrent/atomic/mutex_count_down_latch.rb, line 40 def ns_initialize(count) @count = count end