2003-07-29 18:02:03 +00:00
|
|
|
#ifndef __ruamoko_AutoreleasePool_h
|
|
|
|
#define __ruamoko_AutoreleasePool_h
|
|
|
|
|
|
|
|
#include "Object.h"
|
|
|
|
|
2010-11-22 04:26:23 +00:00
|
|
|
@class Array;
|
|
|
|
|
2010-12-12 04:45:19 +00:00
|
|
|
/**
|
|
|
|
The AutoreleasePool class is an assistant class for reference-counted
|
|
|
|
object management.
|
|
|
|
|
|
|
|
The Ruamoko standard library implements object management using a
|
|
|
|
reference counting scheme, and sometimes it is useful to create objects
|
|
|
|
that have a limited lifespan. For these objects, it is often useful to not
|
|
|
|
have to explicitly free them -- thus the “autorelease” system.
|
|
|
|
|
|
|
|
Autorelease is best described as a “delayed release”, to
|
|
|
|
complement the Object::retain and Object::release methods. It is used
|
|
|
|
when an object is being created on behalf of another object, where the
|
|
|
|
client is not necessarily expected to assume ownership over the object
|
|
|
|
created.
|
|
|
|
*/
|
2003-07-29 18:02:03 +00:00
|
|
|
@interface AutoreleasePool: Object
|
|
|
|
{
|
2011-02-07 13:16:16 +00:00
|
|
|
Array *array; ///< a list of objects awaiting release
|
2003-07-29 18:02:03 +00:00
|
|
|
}
|
|
|
|
|
2010-12-12 04:45:19 +00:00
|
|
|
/**
|
|
|
|
Adds \a anObject to the currently-active (most recently created)
|
|
|
|
autorelease pool.
|
|
|
|
|
|
|
|
\note You should generally not use this method. Instead, send #autorelease
|
|
|
|
to the object you want to add to the pool.
|
|
|
|
*/
|
2003-07-29 18:02:03 +00:00
|
|
|
+ (void) addObject: (id)anObject;
|
2010-12-12 04:45:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds \a anObject to the receiver.
|
|
|
|
|
|
|
|
\note You should generally not use this method (there isn't much reason to
|
|
|
|
add an object to a \a specific autorelease pool). Instead, send
|
|
|
|
#autorelease to the object you want to add to a pool.
|
|
|
|
*/
|
2003-07-29 18:02:03 +00:00
|
|
|
- (void) addObject: (id)anObject;
|
|
|
|
|
2010-12-12 04:45:19 +00:00
|
|
|
/**
|
|
|
|
Generates an error. Never send this message to an instance of this class.
|
|
|
|
*/
|
2010-12-12 04:49:48 +00:00
|
|
|
- (id) retain;
|
2010-12-12 04:45:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Generates an error. Never send this message to an instance of this class.
|
|
|
|
*/
|
|
|
|
- (id) autorelease;
|
|
|
|
|
2003-07-29 18:02:03 +00:00
|
|
|
@end
|
|
|
|
|
2010-12-12 04:23:55 +00:00
|
|
|
@extern void ARP_FreeAllPools (void);
|
2010-12-12 01:25:09 +00:00
|
|
|
|
2003-07-29 18:02:03 +00:00
|
|
|
#endif // __ruamoko_AutoreleasePool_h
|