lib/polyphony/core/resource_pool.rb
# Acquires a resource, passing it to the given block. If no resource is
# available, blocks until a resource becomes available. After the block has
# run, the resource is released back to the pool. The resource is passed to
# the block as its only argument.
#
# This method is re-entrant: if called from the same fiber, it will immediately
# return the resource currently acquired by the fiber.
#
#   rows = db_pool.acquire do |db|
#     db.query(sql).to_a
#   end
#
# @param &block [Proc] code to run
# @return [any] return value of block
Acquires a resource, passing it to the given block. If no resource is
available, blocks until a resource becomes available. After the block has
run, the resource is released back to the pool. The resource is passed to
the block as its only argument.

This method is re-entrant: if called from the same fiber, it will immediately
return the resource currently acquired by the fiber.


Acquires a resource passing it to the given block . If no resource is available blocks until a resource becomes available . After the block has run the resource is released back to the pool . The resource is passed to the block as its only argument . This method is re - entrant : if called from the same fiber it will immediately return the resource currently acquired by the fiber .
def acquire(&block)
      fiber = Fiber.current
      return yield @acquired_resources[fiber] if @acquired_resources[fiber]
      acquire_from_stock(fiber, &block)
    end
def acquire ( & block ) fiber = Fiber . current return yield @acquired_resources [ fiber ] if @acquired_resources [ fiber ] acquire_from_stock ( fiber , & block ) end
Acquires a resource, passing it to the given block.
Acquires a resource passing it to the given block .
return value of block
return value of block
any
block
<not_specific>
&block
<not_specific>
code to run
code to run