mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
complete NSGarbageCollector class
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27653 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
185221a9f4
commit
39b3249632
3 changed files with 43 additions and 12 deletions
|
@ -4,6 +4,8 @@
|
|||
Improve debug logging by including the address of the actual
|
||||
handle concerned so that you can see which handle is doing what
|
||||
when there are multiple handles in use.
|
||||
* Source/NSGarbageCollector.m: Implement last methods.
|
||||
* Headers/Foundation/NSGarbageCollector.h: Improve documentation.
|
||||
|
||||
2009-01-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
@ -114,9 +116,9 @@
|
|||
|
||||
2009-01-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source\NSGarbageCollector.m: Avoid compiler warning
|
||||
* Source\pathconfig/pathconfig.mak.in: Fix syntax error in warning
|
||||
* Headers\Additions\GNUstepBase\GSCategories.h: remove obsolete methods
|
||||
* Source/NSGarbageCollector.m: Avoid compiler warning
|
||||
* Source/pathconfig/pathconfig.mak.in: Fix syntax error in warning
|
||||
* Headers/Additions/GNUstepBase/GSCategories.h: remove obsolete methods
|
||||
* GNUmakefile: Fix order of includes
|
||||
* Source/GSArray.m: Remove unused line from last change
|
||||
* Source/NSNotificationCenter.m: Remove unused line
|
||||
|
|
|
@ -54,18 +54,28 @@ extern "C" {
|
|||
- (void) collectExhaustively;
|
||||
|
||||
/** Disables garbage collection until a corresponding call to -enable is made.
|
||||
* NB. Calls to this method stack, and must be matched by the same number of
|
||||
* calls to the -enable method.
|
||||
*/
|
||||
- (void) disable;
|
||||
|
||||
/** Disables collection for the area of memory pointed at.
|
||||
/** Makes the area of memory pointed at be uncollectable ... that is to say,
|
||||
* the memory will not be collected by the garbage collector. You must not
|
||||
* explicitly free this memory unless you re-enable collection first.<br />
|
||||
* Calls to this method do not stack, so callig it multiple times for the
|
||||
* same pointer has the same effect as calling it once.
|
||||
*/
|
||||
- (void) disableCollectorForPointer: (void *)ptr;
|
||||
|
||||
/** Enables garbage collection prevously disabled by a calle to -disable
|
||||
/** Enables garbage collection prevously disabled by a call to the
|
||||
* -disable method. Since calls to -disable stack, you must make as
|
||||
* many calls to -enable as to -disable in order to re-start collection.
|
||||
*/
|
||||
- (void) enable;
|
||||
|
||||
/** Enables collection for the area of memory pointed at.
|
||||
/** Enables collection for the area of memory pointed at, which must have
|
||||
* previously been made uncollectable by a call to the
|
||||
* -disableCollectorForPointer: method.
|
||||
*/
|
||||
- (void) enableCollectorForPointer: (void *)ptr;
|
||||
|
||||
|
@ -78,6 +88,10 @@ extern "C" {
|
|||
- (BOOL) isEnabled;
|
||||
|
||||
/** Returns a zone for holding non-collectable pointers.<br />
|
||||
* Memory allocated in this zone will be seen by the garbage collector and
|
||||
* collected (so it doesn't need to be freed explicitly), but the presence
|
||||
* of pointers from the memory to other objectrs will not prevent those
|
||||
* other objects from being collected.
|
||||
*/
|
||||
- (NSZone*) zone;
|
||||
@end
|
||||
|
|
|
@ -34,8 +34,9 @@ static unsigned disabled = 0;
|
|||
#include <gc.h>
|
||||
|
||||
#import "Foundation/NSLock.h"
|
||||
static NSLock *lock = nil;
|
||||
|
||||
#import "Foundation/NSHashTable.h"
|
||||
static NSLock *lock = nil;
|
||||
static NSHashTable *uncollectable = 0;
|
||||
#endif
|
||||
|
||||
@implementation NSGarbageCollector
|
||||
|
@ -82,8 +83,16 @@ static NSLock *lock = nil;
|
|||
|
||||
- (void) disableCollectorForPointer: (void *)ptr
|
||||
{
|
||||
// FIXME
|
||||
[self notImplemented: _cmd];
|
||||
#if GS_WITH_GC
|
||||
[lock lock];
|
||||
if (uncollectable == 0)
|
||||
{
|
||||
uncollectable = NSCreateHashTableWithZone(NSOwnedPointerHashCallBacks,
|
||||
0, GSScannedMallocZone());
|
||||
}
|
||||
NSHashInsertIfAbsent(uncollectable, ptr);
|
||||
[lock unlock];
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -103,8 +112,14 @@ static NSLock *lock = nil;
|
|||
|
||||
- (void) enableCollectorForPointer: (void *)ptr
|
||||
{
|
||||
// FIXME
|
||||
[self notImplemented: _cmd];
|
||||
#if GS_WITH_GC
|
||||
[lock lock];
|
||||
if (uncollectable != 0)
|
||||
{
|
||||
NSHashRemove(uncollectable, ptr);
|
||||
}
|
||||
[lock unlock];
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue