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
lazy_record-0.1.8 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.1.7 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.1.6 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.1.4 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
tdiary-5.0.4 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.1.3 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.1.2 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.1.1 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
lazy_record-0.1.0 vendor/bundle/gems/concurrent-ruby-1.0.5/lib/concurrent/atomic/mutex_count_down_latch.rb
concurrent-ruby-1.0.5-java lib/concurrent/atomic/mutex_count_down_latch.rb
concurrent-ruby-1.0.5 lib/concurrent/atomic/mutex_count_down_latch.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/atomic/mutex_count_down_latch.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/atomic/mutex_count_down_latch.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/atomic/mutex_count_down_latch.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/atomic/mutex_count_down_latch.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/atomic/mutex_count_down_latch.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/atomic/mutex_count_down_latch.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.4/lib/concurrent/atomic/mutex_count_down_latch.rb
abaci-0.3.0 vendor/bundle/gems/concurrent-ruby-1.0.4/lib/concurrent/atomic/mutex_count_down_latch.rb
concurrent-ruby-1.0.4-java lib/concurrent/atomic/mutex_count_down_latch.rb