mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39840 72102866-910b-0410-8b05-ffd578937521
61 lines
1.5 KiB
Objective-C
61 lines
1.5 KiB
Objective-C
#import <Foundation/Foundation.h>
|
|
#import "Testing.h"
|
|
|
|
int main()
|
|
{
|
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
|
BOOL ret;
|
|
NSLock *lock = [NSRecursiveLock new];
|
|
|
|
ret = [lock tryLock];
|
|
if (ret)
|
|
[lock unlock];
|
|
PASS(ret, "NSRecursiveLock with tryLock, then unlocking");
|
|
|
|
ret = [lock lockBeforeDate: [NSDate dateWithTimeIntervalSinceNow:1]];
|
|
if (ret)
|
|
[lock unlock];
|
|
PASS(ret, "NSRecursiveLock lockBeforeDate: works");
|
|
|
|
ret = [lock tryLock];
|
|
if (ret)
|
|
{
|
|
ret = [lock lockBeforeDate: [NSDate dateWithTimeIntervalSinceNow:1]];
|
|
if (ret)
|
|
{
|
|
[lock unlock];
|
|
}
|
|
[lock unlock];
|
|
}
|
|
PASS(ret, "NSRecursiveLock lockBeforeDate: with NSRecursiveLock returns YES");
|
|
|
|
#if defined(GNUSTEP_BASE_LIBRARY)
|
|
START_SET("mutex ownership extension")
|
|
#if defined(_WIN32)
|
|
SKIP("mutex ownership feature not available on windows")
|
|
#endif
|
|
NS_DURING
|
|
{
|
|
testHopeful = YES;
|
|
PASS([lock isLockedByCurrentThread] == NO,
|
|
"NSRecursiveLock isLockedByCurrentThread returns NO when not locked");
|
|
[lock lock];
|
|
PASS([lock isLockedByCurrentThread] == YES,
|
|
"NSRecursiveLock isLockedByCurrentThread returns YES when locked");
|
|
[lock unlock];
|
|
PASS([lock isLockedByCurrentThread] == NO,
|
|
"NSRecursiveLock isLockedByCurrentThread returns NO when unlocked");
|
|
testHopeful = NO;
|
|
}
|
|
NS_HANDLER
|
|
{
|
|
NSLog(@"-isLockedByCurrentThread not supported");
|
|
}
|
|
NS_ENDHANDLER
|
|
END_SET("mutex ownership extension")
|
|
#endif
|
|
|
|
[arp release]; arp = nil;
|
|
return 0;
|
|
}
|
|
|