Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- + (id)defaultCenter
- {
- static MAKVONotificationCenter *center = nil;
- if(!center)
- {
- // do a bit of clever atomic setting to make this thread safe
- // if two threads try to set simultaneously, one will fail
- // and the other will set things up so that the failing thread
- // gets the shared center
- MAKVONotificationCenter *newCenter = [[self alloc] init];
- if(!OSAtomicCompareAndSwapPtrBarrier(nil, newCenter, (void *)¢er))
- [newCenter release];
- }
- return center;
- }
Add Comment
Please, Sign In to add comment