# File lib/em-synchrony/connection_pool.rb, line 7 def initialize(opts, &block) @reserved = {} # map of in-progress connections @available = [] # pool of free connections @pending = [] # pending reservations (FIFO) opts[:size].times do @available.push(block.call) if block_given? end end
Choose first available connection and pass it to the supplied block. This will block indefinitely until there is an available connection to service the request.
# File lib/em-synchrony/connection_pool.rb, line 20 def execute(async) f = Fiber.current begin conn = acquire(f) yield conn ensure release(f) if not async end end
Generated with the Darkfish Rdoc Generator 2.