Package pypat :: Package creational :: Module pool :: Class Pool
[hide private]
[frames] | no frames]

Class Pool

source code

object --+
         |
        Pool


An Object Pool design pattern implementation.

- External Usage documentation: U{https://github.com/tylerlaberge/PyPatterns/wiki/Creational-Pattern-Usage}
- External Object Pool Pattern documentation: U{https://en.wikipedia.org/wiki/Object_pool_pattern}

Instance Methods [hide private]
 
__init__(self, reusable_class, *args, **kwargs)
Initialize a new object pool instance.
source code
 
acquire(self)
Acquire an object from the pool.
source code
 
release(self, reusable)
Release an object back into the pool.
source code
 
_expand(self, size) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, reusable_class, *args, **kwargs)
(Constructor)

source code 

Initialize a new object pool instance.

Parameters:
  • reusable_class - The reusable class this object pool is responsible for.
  • args - args for reusable object creation.
  • kwargs - kwargs for reusable object creation.
Overrides: object.__init__

acquire(self)

source code 

Acquire an object from the pool.

Returns:
An object from the pool.

release(self, reusable)

source code 

Release an object back into the pool.

Parameters:
  • reusable - The object to return to the pool.