Parent

Methods

Class/Module Index [+]

Quicksearch

EventMachine::Synchrony::ConnectionPool

Public Class Methods

new(opts, &block) click to toggle source
# 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

Public Instance Methods

execute(async) click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.