Class: WSDirector::ClientsHolder

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdirector/clients_holder.rb

Overview

Acts as a re-usable global barrier for a fixed number of clients. Barrier is reset if sucessfully passed in time.

Instance Method Summary collapse

Constructor Details

#initialize(count, sync_timeout: 5) ⇒ ClientsHolder

Returns a new instance of ClientsHolder.



7
8
9
10
# File 'lib/wsdirector/clients_holder.rb', line 7

def initialize(count, sync_timeout: 5)
  @barrier = Concurrent::CyclicBarrier.new(count)
  @sync_timeout = sync_timeout
end

Instance Method Details

#wait_allObject

Raises:



12
13
14
15
16
17
18
# File 'lib/wsdirector/clients_holder.rb', line 12

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