More changes to make lock tracking more robust

This commit is contained in:
Richard Frith-Macdonald 2018-04-04 14:42:20 +01:00
parent 603c3b1103
commit cc7a146796
6 changed files with 107 additions and 57 deletions

View file

@ -60,12 +60,38 @@ static Class untracedRecursiveLockClass = Nil;
static BOOL traceLocks = NO;
void
GSPrivateTraceLocks(BOOL aFlag)
@implementation NSObject (GSTraceLocks)
+ (BOOL) shouldCreateTraceableLocks: (BOOL)shouldTrace
{
traceLocks = (aFlag ? YES : NO);
BOOL old = traceLocks;
traceLocks = shouldTrace ? YES : NO;
return old;
}
+ (NSCondition*) tracedCondition
{
return AUTORELEASE([GSTracedCondition new]);
}
+ (NSConditionLock*) tracedConditionLockWithCondition: (NSInteger)value
{
return AUTORELEASE([[GSTracedConditionLock alloc] initWithCondition: value]);
}
+ (NSLock*) tracedLock
{
return AUTORELEASE([GSTracedLock new]);
}
+ (NSRecursiveLock*) tracedRecursiveLock
{
return AUTORELEASE([GSTracedRecursiveLock new]);
}
@end
/* In untraced operations these macros do nothing.
* When tracing they are defined to perform the trace methods of the thread.
*/