Sha256: fbd9897d8f2950003cdf10ec9bd196e04d65a28496ed10126bf33c7a06dd12b4

Contents?: true

Size: 970 Bytes

Versions: 43

Compression:

Stored size: 970 Bytes

Contents

require 'concurrent/synchronization'

module Concurrent

  # @!macro count_down_latch
  # @!visibility private
  # @!macro internal_implementation_note
  class MutexCountDownLatch < Synchronization::LockableObject

    # @!macro count_down_latch_method_initialize
    def initialize(count = 1)
      Utility::NativeInteger.ensure_integer_and_bounds count
      Utility::NativeInteger.ensure_positive count

      super()
      synchronize { ns_initialize count }
    end

    # @!macro count_down_latch_method_wait
    def wait(timeout = nil)
      synchronize { ns_wait_until(timeout) { @count == 0 } }
    end

    # @!macro count_down_latch_method_count_down
    def count_down
      synchronize do
        @count -= 1 if @count > 0
        ns_broadcast if @count == 0
      end
    end

    # @!macro count_down_latch_method_count
    def count
      synchronize { @count }
    end

    protected

    def ns_initialize(count)
      @count = count
    end
  end
end

Version data entries

43 entries across 40 versions & 11 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
sprokovuln-0.2.0 vendor/ruby/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.5-java/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.9 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
monero_wallet_gen-0.1.0 vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.8 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.7 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
pract6-0.1.0 .gem/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.6 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.5-java/lib/concurrent/atomic/mutex_count_down_latch.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.5-java/lib/concurrent/atomic/mutex_count_down_latch.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/concurrent-ruby-1.0.5-java/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.5 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.2.1 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.2.0 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.1.9 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb