diff --git a/ESNetworking/ESRunLoopOperation.m b/ESNetworking/ESRunLoopOperation.m index 591cbc4..1fb0949 100644 --- a/ESNetworking/ESRunLoopOperation.m +++ b/ESNetworking/ESRunLoopOperation.m @@ -1,5 +1,5 @@ #import "ESRunLoopOperation.h" -#import +//#import @interface ESRunLoopOperation () // read/write versions of public properties @@ -9,7 +9,7 @@ @interface ESRunLoopOperation () @implementation ESRunLoopOperation { - OSSpinLock stateLock; + NSRecursiveLock *lock; } @synthesize runLoopThread=_runLoopThread; @@ -25,8 +25,8 @@ - (id)init NSAssert((_state == kESOperationStateInited), @"Operation initialized with invalid state: %d", _state); if (_state != kESOperationStateInited) self = nil; - stateLock = OS_SPINLOCK_INIT; - } + lock = [[NSRecursiveLock alloc] init]; + } return self; } @@ -69,9 +69,9 @@ - (NSSet *)actualRunLoopModes - (ESOperationState)state { ESOperationState state; - OSSpinLockLock(&stateLock); + [lock lock]; state = _state; - OSSpinLockUnlock(&stateLock); + [lock unlock]; return state; } @@ -80,7 +80,7 @@ - (void)setState:(ESOperationState)newState { // any thread - OSSpinLockLock(&stateLock); + [lock lock]; ESOperationState oldState; @@ -109,7 +109,7 @@ - (void)setState:(ESOperationState)newState if ((newState == kESOperationStateExecuting) || (oldState == kESOperationStateExecuting)) [self didChangeValueForKey:@"isExecuting"]; - OSSpinLockUnlock(&stateLock); + [lock unlock]; } - (void)startOnRunLoopThread