diff --git a/ChangeLog b/ChangeLog index 086a030..ec1b85d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,12 @@ -2010-03-15 Richard Frith-Macdonald +2010-03-30 David Ayers + + * EOControl/EONSAddOns.m (GSUseStrictWO451Compatibility): Avoid usage + of GS_INITIALIZED_LOCK. + * EOControl/EOPrivate.h/m (GDL2_AssignAtomicallyIfNil): New convenience + function for initializing variables in multithreaded environments. + Reported by: Tim Kack + +2010-03-15 Richard Frith-Macdonald * EOControl/EONSAddOns.h: * EOControl/EONSAddOns.m: @@ -15,7 +23,7 @@ * EOControl/Makefile.postamble: Removed unused dependency rule. -2009-07-29 04:06-EDT Gregory John Casamento +2009-07-29 04:06-EDT Gregory John Casamento * EOControl/EOKeyValueArchiver.h: Add forward declaration of NSMutableArray. diff --git a/EOControl/EONSAddOns.m b/EOControl/EONSAddOns.m index 52256a4..3e571b5 100644 --- a/EOControl/EONSAddOns.m +++ b/EOControl/EONSAddOns.m @@ -79,7 +79,12 @@ GSUseStrictWO451Compatibility (NSString *key) static BOOL read = NO; if (read == NO) { - [GS_INITIALIZED_LOCK(local_lock, GSLazyRecursiveLock) lock]; + if (local_lock == nil) + { + NSRecursiveLock *l = [GSLazyRecursiveLock new]; + GDL2_AssignAtomicallyIfNil(&local_lock, l); + } + [local_lock lock]; NS_DURING if (read == NO) diff --git a/EOControl/EOPrivate.h b/EOControl/EOPrivate.h index 7032596..8d0785e 100644 --- a/EOControl/EOPrivate.h +++ b/EOControl/EOPrivate.h @@ -101,6 +101,7 @@ GDL2CONTROL_EXPORT NSArray* GDL2_NSArray; // ==== Init Method ==== GDL2CONTROL_EXPORT void GDL2_PrivateInit(); +GDL2CONTROL_EXPORT void GDL2_AssignAtomicallyIfNil (id *address,id value); // ==== IMP Helpers ==== diff --git a/EOControl/EOPrivate.m b/EOControl/EOPrivate.m index f0f9497..475a2d6 100644 --- a/EOControl/EOPrivate.m +++ b/EOControl/EOPrivate.m @@ -39,6 +39,7 @@ RCS_ID("$Id$") #define GSI_ARRAY_NO_RETAIN 1 #define GSI_ARRAY_NO_RELEASE 1 #include +#include #ifndef GNUSTEP #include @@ -110,6 +111,9 @@ NSNumber* GDL2_NSNumberBool_No=nil; EONull* GDL2_EONull=nil; NSArray* GDL2_NSArray=nil; +// ==== Private Variables ==== +static NSRecursiveLock *GDL2_Lock=nil; + // ==== Init Method ==== void GDL2_PrivateInit() { @@ -118,6 +122,8 @@ void GDL2_PrivateInit() { initialized = YES; + GDL2_Lock = [GSLazyRecursiveLock new]; + // ==== Classes ==== GDL2_NSArrayClass=[NSArray class]; GDL2_NSMutableArrayClass=[NSMutableArray class]; @@ -208,6 +214,18 @@ void GDL2_PrivateInit() }; } +void +GDL2_AssignAtomicallyIfNil (id *address,id value) +{ + GDL2_PrivateInit(); + [GDL2_Lock lock]; + if (address && *address == nil) + { + *address = value; + } + [GDL2_Lock unlock]; +} + /* EOMultipleKnownKeyDictionary */ id