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:
Richard Frith-MacDonald 2009-01-22 15:47:10 +00:00
parent 185221a9f4
commit 39b3249632
3 changed files with 43 additions and 12 deletions

View file

@ -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;
}