Wrapping network thread lazy initializer with dispatch_once, to ensure thread safety
This commit is contained in:
parent
c0271e6156
commit
a167217ee6
1 changed files with 4 additions and 2 deletions
|
|
@ -108,10 +108,12 @@ static inline BOOL AFHTTPOperationStateTransitionIsValid(AFHTTPOperationState fr
|
|||
static NSThread *_networkRequestThread = nil;
|
||||
|
||||
+ (NSThread *)networkRequestThread {
|
||||
if (!_networkRequestThread) {
|
||||
static dispatch_once_t oncePredicate;
|
||||
|
||||
dispatch_once(&oncePredicate, ^{
|
||||
_networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil];
|
||||
[_networkRequestThread start];
|
||||
}
|
||||
});
|
||||
|
||||
return _networkRequestThread;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue