* EOControl/EOClassDescription.m

([EOClassDescription initialize]): Use local
        GSLazyRecursiveLock instead of old locking mechanism.
        ([EOClassDescription classDelegate]): Ditto.
        * EOControl/EOGenericRecord.m:  Use GSLazyRecursiveLock
        instead of NSRecursiveLock.
        * EOControl/EONSAddOns.h/m (GDL2GlobalLock,
        GDL2GlobalRecursiveLock) Remove.
        (GDL2GlobalLockVendor) Ditto.
        (GSUseStrictWO451Compatibility): Use local GSLazyRecursiveLock
        instead of old locking mechanism.
        * EOControl/EOFault.m: Remove superfluous include.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@18587 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2004-02-12 11:07:49 +00:00
parent ed101c8d44
commit b6e8074c69
6 changed files with 32 additions and 139 deletions

View file

@ -1,5 +1,18 @@
2003-02-12 David Ayers <d.ayers@inode.at>
* EOControl/EOClassDescription.m
([EOClassDescription initialize]): Use local
GSLazyRecursiveLock instead of old locking mechanism.
([EOClassDescription classDelegate]): Ditto.
* EOControl/EOGenericRecord.m: Use GSLazyRecursiveLock
instead of NSRecursiveLock.
* EOControl/EONSAddOns.h/m (GDL2GlobalLock,
GDL2GlobalRecursiveLock) Remove.
(GDL2GlobalLockVendor) Ditto.
(GSUseStrictWO451Compatibility): Use local GSLazyRecursiveLock
instead of old locking mechanism.
* EOControl/EOFault.m: Remove superfluous include.
* EOControl/EOKeyValueQualifier.m
([EOKeyValueQualifier initWithKey:operatorSelector:value:]):
Use EONull instance if value is nil.

View file

@ -104,6 +104,7 @@ NSString *EOValidatedPropertyUserInfoKey = @"EOValidatedPropertyUserInfoKey";
static NSMapTable *classDescriptionForEntity = NULL;
static NSMapTable *classDescriptionForClass = NULL;
static id classDelegate = nil;
static NSRecursiveLock *local_lock = nil;
+ (void)initialize
{
@ -111,6 +112,7 @@ static id classDelegate = nil;
{
Class cls = NSClassFromString(@"EOModelGroup");
local_lock = [GSLazyRecursiveLock new];
classDescriptionForClass = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSObjectMapValueCallBacks,
32);
@ -132,22 +134,15 @@ static id classDelegate = nil;
+ (id)classDelegate
{
id delegate;
NSLock *lock = GDL2GlobalLock();
if (lock == nil)
[local_lock lock];
delegate = classDelegate;
if (delegate != nil)
{
delegate = classDelegate;
}
else
{
[lock lock];
delegate = classDelegate;
if (delegate != nil)
{
AUTORELEASE(RETAIN(delegate));
}
[lock unlock];
AUTORELEASE(RETAIN(delegate));
}
[local_lock unlock];
return delegate;
}

View file

@ -47,7 +47,6 @@ RCS_ID("$Id$")
#include <Foundation/NSString.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSInvocation.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSException.h>
#include <Foundation/NSDebug.h>
#else

View file

@ -43,7 +43,6 @@ RCS_ID("$Id$")
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSHashTable.h>
#include <Foundation/NSDebug.h>
@ -57,6 +56,8 @@ RCS_ID("$Id$")
#include <GNUstepBase/GSCategories.h>
#endif
#include <GNUstepBase/GSLock.h>
#include <EOControl/EOClassDescription.h>
#include <EOControl/EOGenericRecord.h>
#include <EOControl/EONull.h>
@ -111,7 +112,7 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
{
allGenericRecords = NSCreateHashTable(NSNonOwnedPointerHashCallBacks,
1000);
allGenericRecordsLock = [NSRecursiveLock new];
allGenericRecordsLock = [GSLazyRecursiveLock new];
}
}

View file

@ -46,18 +46,9 @@
: ( TYPE *)GSAutoreleasedBuffer((ID##_size) * sizeof( TYPE )); \
TYPE *ID = ID##_base;
@class NSLock;
@class NSRecursiveLock;
GDL2CONTROL_EXPORT BOOL
GSUseStrictWO451Compatibility(NSString *key);
GDL2CONTROL_EXPORT NSLock *
GDL2GlobalLock();
GDL2CONTROL_EXPORT NSRecursiveLock *
GDL2GlobalRecursiveLock();
@interface NSObject (NSObjectPerformingSelector)
- (NSArray*)resultsOfPerformingSelector: (SEL)sel
withEachObjectInArray: (NSArray*)array;

View file

@ -40,7 +40,6 @@ RCS_ID("$Id$")
#include <Foundation/NSArray.h>
#include <Foundation/NSScanner.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSThread.h>
@ -55,10 +54,12 @@ RCS_ID("$Id$")
#include <GNUstepBase/GSCategories.h>
#include <GNUstepBase/GSObjCRuntime.h>
#endif
#include <GNUstepBase/GSLock.h>
#include <EOControl/EONSAddOns.h>
#include <EOControl/EODebug.h>
static NSRecursiveLock *local_lock = nil;
static BOOL GSStrictWO451Flag = NO;
BOOL
@ -67,11 +68,8 @@ GSUseStrictWO451Compatibility (NSString *key)
static BOOL read = NO;
if (read == NO)
{
NSLock *lock = GDL2GlobalLock();
if (lock!=nil)
{
[lock lock];
}
[GS_INITIALIZED_LOCK(local_lock, GSLazyRecursiveLock) lock];
NS_DURING
if (read == NO)
{
@ -82,42 +80,15 @@ GSUseStrictWO451Compatibility (NSString *key)
read = YES;
}
NS_HANDLER
if (lock != nil)
{
[lock unlock];
}
[local_lock unlock];
[localException raise];
NS_ENDHANDLER
if (lock != nil)
{
[lock unlock];
}
[local_lock unlock];
}
return GSStrictWO451Flag;
}
/* We use this helper class because the runtime
guarantees to call +initialize under a mutex,
allowing for clean setup of the global locks.*/
@interface GDL2GlobalLockVendor : NSObject
+ (NSLock *) globalLock;
+ (NSRecursiveLock *) globalRecursiveLock;
@end
NSLock *
GDL2GlobalLock()
{
return [GDL2GlobalLockVendor globalLock];
}
NSRecursiveLock *
GDL2GlobalRecursiveLock()
{
return [GDL2GlobalLockVendor globalRecursiveLock];
}
@implementation NSObject (NSObjectPerformingSelector)
- (NSArray*)resultsOfPerformingSelector: (SEL)sel
@ -548,83 +519,6 @@ GDL2GlobalRecursiveLock()
}
@end
@interface GDL2GlobalLockVendor (private)
+ (void) _setupLocks: (NSNotification *)notif;
@end
@implementation GDL2GlobalLockVendor
static NSLock *lock = nil;
static NSRecursiveLock *rlock = nil;
/*
* Depending on whether we are multithreaded or not, we
* setup for the becomeMultithreadedNotification to
* invoke _setupLocks: or invoke it directly. This method
* is invoked once by the runtime under a lock and
* therefor allows thread safe access to global variables.
*/
+ (void) initialize
{
if (self == [GDL2GlobalLockVendor class])
{
if ([NSThread isMultiThreaded] == YES)
{
[self _setupLocks: nil];
}
else
{
NSNotificationCenter *nc;
nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self
selector:@selector(_setupLocks:)
name: NSWillBecomeMultiThreadedNotification
object: nil];
}
}
}
/*
* Setup globalLock and globalRecursiveLock. This method should
* only be called from a thread safe context (i.e. from +initialze
* or during NSWillBecomeMultiThreadedNotification).
*/
+ (void) _setupLocks: (NSNotification *)notif
{
if (lock == nil && rlock == nil)
{
lock = [NSLock new];
rlock = [NSRecursiveLock new];
}
else
{
NSLog(@"%@ - +%@ called multiple times!",
NSStringFromClass([self class]),
NSStringFromSelector(_cmd));
}
}
/**
* Returns a global NSLock, if the process is multithreaded.
* Otherwise returns nil.
*/
+ (NSLock *) globalLock
{
return lock;
}
/**
* Returns a global NSRecursiveLock, if the process is multithreaded.
* Otherwise returns nil.
*/
+ (NSRecursiveLock *) globalRecursiveLock
{
return rlock;
}
@end
@implementation NSString (StringToNumber)
-(unsigned int)unsignedIntValue
{