Class: WSDirector::ClientsHolder
- Inherits:
-
Object
- Object
- WSDirector::ClientsHolder
- 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
-
#initialize(count, sync_timeout: 5) ⇒ ClientsHolder
constructor
A new instance of ClientsHolder.
- #wait_all ⇒ Object
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_all ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/wsdirector/clients_holder.rb', line 12 def wait_all result = .wait(sync_timeout) raise Error, "Timeout (#{sync_timeout}s) exceeded for #wait_all" unless result .reset result end |