Class ConnectionPool::TimedStack
In: lib/connection_pool/timed_stack.rb
Parent: Object

Examples:

   ts = TimedStack.new(1) { MyConnection.new }

   # fetch a connection
   conn = ts.pop

   # return a connection
   ts.push conn

   conn = ts.pop
   ts.pop timeout: 5
   #=> raises Timeout::Error after 5 seconds

Methods

<<   empty?   length   new   pop   push   shutdown  

Attributes

max  [R] 

Public Class methods

Creates a new pool with size connections that are created from the given block.

Public Instance methods

<<(obj, options = {})

Alias for push

Returns true if there are no available connections.

The number of connections available on the stack.

Retrieves a connection from the stack. If a connection is available it is immediately returned. If no connection is available within the given timeout a Timeout::Error is raised.

+:timeout+ is the only checked entry in options and is preferred over the timeout argument (which will be removed in a future release). Other options may be used by subclasses that extend TimedStack.

Returns obj to the stack. options is ignored in TimedStack but may be used by subclasses that extend TimedStack.

Shuts down the TimedStack which prevents connections from being checked out. The block is called once for each connection on the stack.

[Validate]