List of all members.
Public Member Functions
|Add the given object to this reaper. |
|Return the number of objects currently scheduled for destruction. |
Initializers and Deallocators
|Free all objects that have been added to this reaper and free the reaper. |
|Initialize a new reaper. |
Static Public Member Functions
|(OLReaper *)||+ currentReaper|
|Retrieve the reaper currently in use. |
|Initialize the class. |
|The array of as-yet-uncleaned-up objects. |
This class is fundamentally equivalent to NSAutoreleasePool from OpenStep. Each thread contains a list of active reapers. Calling currentReaper (OLReaper) will return the head of the current thread's list, thus the most recently defined reaper. When a reaper is freed it will free all of the objects that it has been given to reap.
Typcial usage would be to create a reaper at some point in the code at a high level, for example in
main(), and then to add allocated objects to the reaper instead of trying to manage all the memory by hand. For example, imagine in the following example that a reaper has been created in the application's
OLReaper reaper = [OLReaper currentReaper]; OLTextBuffer* buffer = [reaper reap: [OLTextBuffer textBuffer]]; [buffer appendChars: charBuf fromOffset: 0 count: 8192]; [buffer appendText: [reaper reap: [OLText textWithCString: "Hi, there"]]] // Do something with the text from the buffer ... [reaper reap: [buffer text]] ...
Note that in the above example memory management is handled by the reaper. All of the allocated objects added to the reaper will be cleaned up when the reaper is freed.
|+ (OLReaper*) currentReaper|
Retrieve the reaper currently in use.
This reaper will be the most recently defined OLReaper in the current thread.
|- (id) free|
Free all objects that have been added to this reaper and free the reaper.
That's free the reaper, not fear the reaper.
|- (id) init|
Initialize a new reaper.
The reaper contains no objects to free.
|+ (id) initialize|
Initialize the class.
This for the runtime system to call. Please don't call this method.
|- (id) reap:||(id)||object|
Add the given object to this reaper.
The object will be freed when the reaper is freed.
|object||the object to reap|
|- (unsigned) size|
Return the number of objects currently scheduled for destruction.
|- (OLVectorJunior*) undead
The array of as-yet-uncleaned-up objects.