Minor tidyups.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18558 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2004-02-08 09:23:09 +00:00
parent 08a7ccf232
commit 4b431aa0cc
2 changed files with 16 additions and 56 deletions

View file

@ -1,3 +1,8 @@
2004-02-08 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSConection.m: Simplify code by using GSLazyLock and
GSRecursiveLazylock. Removed unused include of float.h
2004-02-07 Adam Fedor <fedor@gnu.org>
* Source/simple-load.h (__objc_dynamic_get_symbol_path): Remove

View file

@ -30,9 +30,7 @@
#include "config.h"
#include "GNUstepBase/preface.h"
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
#include "GNUstepBase/GSLock.h"
/*
* Setup for inline operation of pointer map tables.
@ -299,7 +297,6 @@ setRootObjectForInPort(id anObj, NSPort *aPort)
static NSMapTable *targetToCached = NULL;
static NSLock *cached_proxies_gate = nil;
static BOOL multi_threaded = NO;
@ -310,46 +307,6 @@ static BOOL multi_threaded = NO;
*/
@implementation NSConnection
/*
* When the system becomes multithreaded, we set a flag to say so and
* make sure that connection locking is enabled.
*/
+ (void) _becomeThreaded: (NSNotification*)notification
{
if (multi_threaded == NO)
{
NSHashEnumerator enumerator;
NSConnection *c;
multi_threaded = YES;
if (connection_table_gate == nil)
{
connection_table_gate = [NSLock new];
}
if (cached_proxies_gate == nil)
{
cached_proxies_gate = [NSLock new];
}
if (root_object_map_gate == nil)
{
root_object_map_gate = [NSLock new];
}
enumerator = NSEnumerateHashTable(connection_table);
while ((c = (NSConnection*)NSNextHashEnumeratorItem(&enumerator)) != nil)
{
if (c->_refGate == nil)
{
c->_refGate = [NSRecursiveLock new];
}
}
NSEndHashTableEnumeration(&enumerator);
}
[[NSNotificationCenter defaultCenter]
removeObserver: self
name: NSWillBecomeMultiThreadedNotification
object: nil];
}
/**
* Returns an array containing all the NSConnection objects known to
* the system. These connections will be valid at the time that the
@ -551,17 +508,18 @@ static BOOL multi_threaded = NO;
root_object_map =
NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
if ([NSThread isMultiThreaded])
if (connection_table_gate == nil)
{
[self _becomeThreaded: nil];
connection_table_gate = [GSLazyLock new];
}
else
if (cached_proxies_gate == nil)
{
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(_becomeThreaded:)
name: NSWillBecomeMultiThreadedNotification
object: nil];
cached_proxies_gate = [GSLazyLock new];
}
if (root_object_map_gate == nil)
{
root_object_map_gate = [GSLazyLock new];
}
}
}
@ -904,10 +862,7 @@ static BOOL multi_threaded = NO;
_requestDepth = 0;
_delegate = nil;
if (multi_threaded == YES)
{
_refGate = [NSRecursiveLock new];
}
_refGate = [GSLazyRecursiveLock new];
/*
* Some attributes are inherited from the parent if possible.