class EM::Synchrony::ActiveRecord::ConnectionPool

Public Instance Methods

acquire(fiber) click to toggle source
Calls superclass method
# File lib/em-synchrony/activerecord.rb, line 135
def acquire(fiber)
  return @reserved[fiber.object_id] if @reserved[fiber.object_id]
  super
end
affected_rows(*args, &blk) click to toggle source

via method_missing affected_rows will be recognized as async method

# File lib/em-synchrony/activerecord.rb, line 145
def affected_rows(*args, &blk)
  execute(false) do |conn|
    conn.send(:affected_rows, *args, &blk)
  end
end
connection() click to toggle source
# File lib/em-synchrony/activerecord.rb, line 140
def connection
  acquire(Fiber.current)
end
execute(async) { |conn| ... } click to toggle source

consider connection acquired

# File lib/em-synchrony/activerecord.rb, line 123
def execute(async)
  f = Fiber.current
  begin
    conn = acquire(f)
    conn.acquired_for_connection_pool += 1
    yield conn
  ensure
    conn.acquired_for_connection_pool -= 1
    release(f) if !async && conn.acquired_for_connection_pool == 0
  end
end