Sha256: 0f9f325ad14aea1f52e4719d02c4f4669ab2f5f4fffc65de8ab38704ee92fec6
Contents?: true
Size: 591 Bytes
Versions: 5
Compression:
Stored size: 591 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, sync_timeout: 5) @barrier = Concurrent::CyclicBarrier.new(count) @sync_timeout = sync_timeout end def wait_all result = barrier.wait(sync_timeout) raise Error, "Timeout (#{sync_timeout}s) exceeded for #wait_all" unless result barrier.reset result end private attr_reader :barrier, :sync_timeout end end
Version data entries
5 entries across 5 versions & 1 rubygems