lib/polyphony/core/resource_pool.rb
# Acquires a resource from stock, yielding it to the given block.
#
# @param fiber [Fiber] the fiber the resource will be associated with
# @param &block [Proc] given block
# @return [any] return value of block
Acquires a resource from stock, yielding it to the given block.
Acquires a resource from stock yielding it to the given block .
def acquire_from_stock(fiber)
      add_to_stock if (@stock.empty? || @stock.pending?) && @size < @limit
      resource = @stock.shift
      @acquired_resources[fiber] = resource
      yield resource
    ensure
      if resource && @acquired_resources[fiber] == resource
        @acquired_resources.delete(fiber)
        @stock.push resource
      end
    end
def acquire_from_stock ( fiber ) add_to_stock if ( @stock . empty? || @stock . pending? ) && @size < @limit resource = @stock . shift @acquired_resources [ fiber ] = resource yield resource ensure if resource && @acquired_resources [ fiber ] == resource @acquired_resources . delete ( fiber ) @stock . push resource end end
Acquires a resource from stock, yielding it to the given block.
Acquires a resource from stock yielding it to the given block .
return value of block
return value of block
any
fiber
the fiber the resource will be associated with
the fiber the resource will be associated with
&block
<not_specific>
None