template class Poco::AutoReleasePool

Overview

An AutoReleasePool implements simple garbage collection for reference-counted objects. More…

#include <AutoReleasePool.h>

template <class C>
class AutoReleasePool
{
public:
    // methods

    void
    add(C* pObject);

    void
    release();
};

Detailed Documentation

An AutoReleasePool implements simple garbage collection for reference-counted objects.

It temporarily takes ownwership of reference-counted objects that nobody else wants to take ownership of and releases them at a later, appropriate point in time.

Note: The correct way to add an object hold by an AutoPtr<> to an AutoReleasePool is by invoking the AutoPtr ‘s duplicate() method. Example:

AutoReleasePool<C> arp;
AutoPtr<C> ptr = new C;
...
arp.add(ptr.duplicate());

Construction

~AutoReleasePool()

Destroys the AutoReleasePool and releases all objects it currently holds.

Methods

void
add(C* pObject)

Adds the given object to the AutoReleasePool.

The object’s reference count is not modified

void
release()

Releases all objects the AutoReleasePool currently holds by calling each object’s release() method.