* 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:
ayers 2003-10-30 13:44:55 +00:00
parent b462208383
commit 86f35c472c
11 changed files with 471 additions and 25 deletions

View file

@ -447,8 +447,40 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
beforeDate: (NSDate*)limitDate
{
#ifndef HAVE_OBJC_CONDITION_TIMEDWAIT
[self notImplemented: _cmd];
GSSleepInfo ctxt;
CHECK_RECURSIVE_CONDITION_LOCK(_mutex);
GSSleepInit(limitDate, &ctxt);
do
{
if (_condition_value == condition_to_meet)
{
while (objc_mutex_trylock(_mutex) == -1)
{
if (GSSleepOrFail(&ctxt) == NO)
{
return NO;
}
}
if (_condition_value == condition_to_meet)
{
return YES;
}
if (objc_mutex_unlock(_mutex) == -1)
{
[NSException raise: NSConditionLockException
format: @"%s failed to unlock mutex",
GSNameFromSelector(_cmd)];
/* NOT REACHED */
}
}
}
while (GSSleepOrFail(&ctxt) == YES);
return NO;
#else
NSTimeInterval atimeinterval;
struct timespec endtime;