Commit a1b881f4 authored by Gleb Pinigin's avatar Gleb Pinigin Committed by Felix Paul Kühne

Modern approach for creating shared instances(iOS4.0+/OSX10.6+)

Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent 52edcaf6
......@@ -168,12 +168,11 @@ static void * EventDispatcherMainLoop(void * user_data)
@implementation VLCEventManager
+ (id)sharedManager
{
static dispatch_once_t onceToken;
static VLCEventManager *defaultManager = nil;
if (defaultManager == nil)
@synchronized([VLCEventManager class]) {
defaultManager = [[VLCEventManager alloc] init];
}
dispatch_once(&onceToken, ^{
defaultManager = [[VLCEventManager alloc] init];
});
return defaultManager;
}
......
......@@ -49,11 +49,11 @@ static void * sharedInstance = nil;
@implementation VLCLibrary
+ (VLCLibrary *)sharedLibrary
{
if (!sharedLibrary) {
/* Initialize a shared instance */
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedLibrary = [[self alloc] init];
sharedInstance = sharedLibrary.instance;
}
});
return sharedLibrary;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment