template class Poco::PoolableObjectFactory

Overview

A PoolableObjectFactory is responsible for creating and resetting objects managed by an ObjectPool. Moreā€¦

#include <ObjectPool.h>

template <
    class C,
    class P = C*
    >
class PoolableObjectFactory
{
public:
    // methods

    P
    createObject();

    bool
    validateObject(P pObject);

    void
    activateObject(P pObject);

    void
    deactivateObject(P pObject);

    void
    destroyObject(P pObject);
};

Detailed Documentation

A PoolableObjectFactory is responsible for creating and resetting objects managed by an ObjectPool.

Together with an ObjectPool, a PoolableObjectFactory is used as a policy class to change the behavior of the ObjectPool when creating new objects, returning used objects back to the pool and destroying objects, when the pool itself is destroyed or shrinked.

Methods

P
createObject()

Create and return a new object.

bool
validateObject(P pObject)

Checks whether the object is still valid and can be reused.

Returns true if the object is valid, false otherwise.

To maintain the integrity of the pool, this method must not throw an exception.

void
activateObject(P pObject)

Called before an object is handed out by the pool.

Also called for newly created objects, before they are given out for the first time.

void
deactivateObject(P pObject)

Called after an object has been given back to the pool and the object is still valid (a prior call to validateObject() returned true).

To maintain the integrity of the pool, this method must not throw an exception.

void
destroyObject(P pObject)

Destroy an object.

To maintain the integrity of the pool, this method must not throw an exception.