ObjFW
Public Member Functions | Static Public Member Functions | Protected Attributes
OFAutoreleasePool Class Reference

A pool that keeps track of objects to release. More...

#include <OFAutoreleasePool.h>

Inheritance diagram for OFAutoreleasePool:
OFObject <OFObject>

List of all members.

Public Member Functions

void addObject: (id obj)
void releaseObjects ()
void release ()
void drain ()

Static Public Member Functions

void addObject: (id obj)
void releaseAll ()

Protected Attributes

OFAutoreleasePoolnext
OFAutoreleasePoolprev
id * objects
size_t count
size_t size

Detailed Description

A pool that keeps track of objects to release.

The OFAutoreleasePool class is a class that keeps track of objects that will be released when the autorelease pool is released.

Every thread has its own stack of autorelease pools.


Member Function Documentation

void OFAutoreleasePool::addObject: ( id  obj) [static, virtual]

Adds an object to the autorelease pool at the top of the thread-specific stack.

Parameters:
objThe object to add to the autorelease pool
void OFAutoreleasePool::addObject: ( id  obj) [virtual]

Adds an object to the specific autorelease pool.

Parameters:
objThe object to add to the autorelease pool
void OFAutoreleasePool::drain ( ) [virtual]

Calling drain is equivalent to calling release.

If a garbage collector is added in the future, it will tell the GC that now is a good time to clean up.

void OFAutoreleasePool::release ( ) [virtual]

Releases all objects in the autorelease pool and deallocates the pool.

Reimplemented from <OFObject>.

void OFAutoreleasePool::releaseObjects ( ) [virtual]

Releases all objects in the autorelease pool.

This does not free the memory allocated to store pointers to the objects in the pool, so reusing the pool does not allocate any memory until the previous number of objects is exceeded. It behaves this way to optimize loops that always work with the same or similar number of objects and call relaseObjects at the end of the loop, which is propably the most common case for releaseObjects.

If a garbage collector is added in the future, it will tell the GC that now is a good time to clean up, as this is often used after a lot of objects have been added to the pool that should be released before the next iteration of a loop, which adds objects again. Thus, it is usually a clean up call.


The documentation for this class was generated from the following files:
 All Classes Functions Variables