Skip to content

Instantly share code, notes, and snippets.

@Nub
Created September 30, 2011 20:43
Show Gist options
  • Select an option

  • Save Nub/1254920 to your computer and use it in GitHub Desktop.

Select an option

Save Nub/1254920 to your computer and use it in GitHub Desktop.
static void *volatile _dlManagerInstance = nil;
+ (DownloadManager *) sharedInstance {
while (!_dlManagerInstance) {
DownloadManager *temp = [[self alloc] init];
if(!OSAtomicCompareAndSwapPtrBarrier(0x0, temp, &_dlManagerInstance)) {
[temp release];
}
}
return _dlManagerInstance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment