* Headers/Additions/GNUstepBase/GSLock.h: Added missing

forward declaration.
	* Headers/Additions/GNUstepBase/GSCategories.h: Remove
	declaraion of gnustep_global_lock.
	(GS_INITIALIZED_LOCK): New macro.
	(+[NSLock newLockAt:]): New method.
	(+[NSRecursiveLock newLockAt:]): Ditto.
	* Headers/Foundation/NSLock.h: Ditto.
	* Source/Additions/GSCategories.m: Replace global lock with
	local lock.
	(_GSLockInitializer): New class to initialize local lock
	safely.
	(newLockAt): New static function shared by +newLockAt:
	implementations to safely intialize lock variables.
	(+[NSLock newLockAt:]): Implemented and documented.
	(+[NSRecursiveLock newLockAt:]): Ditto.
	* Source/Additions/GSCompatibility.m: Remove
	gnustep_global_lock.
	* Source/Additions/GSObjCRuntime.m: Remove superfluous
	locking.
	* Source/Additions/Unicode.m: Use new GS_INITIALIZED_LOCK
	macro and replace global lock with local lock.
	* Source/NSLock.m
	(-[NSConditionLock lockWhenCondition:beforeDate:]):
	Implemented.
	* Testing/gslock.m: New test case.
	* Testing/GNUmakefile: Add new test case.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18010 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2003-10-30 13:44:55 +00:00
parent 5ac3721b5d
commit c2b8811456
11 changed files with 471 additions and 25 deletions

View file

@ -128,4 +128,42 @@
@end
#ifndef NO_GNUSTEP
/**
* Returns IDENT which will be initialized
* to an instance of a CLASSNAME in a thread safe manner.
* If IDENT has been previoulsy initilized
* this macro merely returns IDENT.
* IDENT is considered uninitialzed, if it contains nil.
* CLASSNAME must be either NSLock, NSRecursiveLock or one
* of thier subclasses.
* See [NSLock+newLockAt:] for details.
* This macro is intended for code that cannot insure
* that a lock can be initialized in thread safe manner otherwise.
* <example>
* NSLock *my_lock = nil;
*
* void function (void)
* {
* [GS_INITIALIZED_LOCK(my_lock, NSLock) lock];
* do_work ();
* [my_lock unlock];
* }
*
* </example>
*/
#define GS_INITIALIZED_LOCK(IDENT,CLASSNAME) \
(IDENT != nil ? IDENT : [CLASSNAME newLockAt: &IDENT])
@interface NSLock (GSCategories)
+ (id)newLockAt:(id *)location;
@end
@interface NSRecursiveLock (GSCategories)
+ (id)newLockAt:(id *)location;
@end
#endif /* NO_GNUSTEP */
#endif /* _GNUstep_H_NSLock*/