* 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


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30078 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2010-03-30 09:10:01 +00:00
parent 61e2658de9
commit 719c9cedc1
4 changed files with 35 additions and 3 deletions

View file

@ -1,4 +1,12 @@
2010-03-15 Richard Frith-Macdonald <rfm@gnu.org>
2010-03-30 David Ayers <ayers@fsfe.org>
* 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 <rfm@gnu.org>
* 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 <greg.casamento@gmail.com>
2009-07-29 04:06-EDT Gregory John Casamento <greg.casamento@gmail.com>
* EOControl/EOKeyValueArchiver.h: Add forward declaration of
NSMutableArray.

View file

@ -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)

View file

@ -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 ====

View file

@ -39,6 +39,7 @@ RCS_ID("$Id$")
#define GSI_ARRAY_NO_RETAIN 1
#define GSI_ARRAY_NO_RELEASE 1
#include <GNUstepBase/GSIArray.h>
#include <GNUstepBase/GSLock.h>
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
@ -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