Sha256: b6784c8413ebb5dbe604398e646444958af0c82aa3418297ad344bd1d4bc4632

Contents?: true

Size: 280 Bytes

Versions: 9

Compression:

Stored size: 280 Bytes

Contents

# frozen_string_literal: true

module Griffin
  class CountingSemaphore
    def initialize(size)
      @size = size
      @queue = Queue.new
      @size.times { @queue.push(0) }
    end

    def wait
      @queue.pop
    end

    def signal
      @queue.push(0)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
griffin-0.1.9 lib/griffin/counting_semaphore.rb
griffin-0.1.8 lib/griffin/counting_semaphore.rb
griffin-0.1.7 lib/griffin/counting_semaphore.rb
griffin-0.1.6 lib/griffin/counting_semaphore.rb
griffin-0.1.5 lib/griffin/counting_semaphore.rb
griffin-0.1.4 lib/griffin/counting_semaphore.rb
griffin-0.1.3 lib/griffin/counting_semaphore.rb
griffin-0.1.2 lib/griffin/counting_semaphore.rb
griffin-0.1.1 lib/griffin/counting_semaphore.rb