Sha256: c62a19416d9a8f462c648f65de31ec8765a7cd05b64e92b86fa79fc0a0035aee

Contents?: true

Size: 560 Bytes

Versions: 4

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

module WSDirector
  # Acts as a re-usable global barrier for a fixed number of clients.
  # Barrier is reset if sucessfully passed in time.
  class ClientsHolder
    def initialize(count)
      @barrier = Concurrent::CyclicBarrier.new(count)
    end

    def wait_all
      result = barrier.wait(WSDirector.config.sync_timeout)
      raise Error, "Timeout (#{WSDirector.config.sync_timeout}s) exceeded for #wait_all" unless
        result
      barrier.reset
      result
    end

    private

    attr_reader :barrier
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wsdirector-cli-0.5.0 lib/wsdirector/clients_holder.rb
wsdirector-cli-0.4.0 lib/wsdirector/clients_holder.rb
wsdirector-cli-0.3.0 lib/wsdirector/clients_holder.rb
wsdirector-cli-0.2.1 lib/wsdirector/clients_holder.rb