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/atomic/mutex_count_down_latch.rb, line 11
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/atomic/mutex_count_down_latch.rb, line 33
def count
  synchronize { @count }
end
count_down() click to toggle source

@!macro count_down_latch_method_count_down

# File lib/concurrent/atomic/mutex_count_down_latch.rb, line 25
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/atomic/mutex_count_down_latch.rb, line 20
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/atomic/mutex_count_down_latch.rb, line 39
def ns_initialize(count)
  @count = count
end