[vlc-devel] [PATCH 2/3] VLCEventManager: synchronize creation of shared object
Gleb Pinigin
gpinigin at gmail.com
Mon Jun 10 07:12:21 CEST 2013
---
Sources/VLCEventManager.m | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/Sources/VLCEventManager.m b/Sources/VLCEventManager.m
index 9018ad7..203542e 100644
--- a/Sources/VLCEventManager.m
+++ b/Sources/VLCEventManager.m
@@ -166,11 +166,12 @@ static void * EventDispatcherMainLoop(void * user_data)
@implementation VLCEventManager
+ (id)sharedManager
{
- static VLCEventManager *defaultManager = NULL;
+ static VLCEventManager *defaultManager = nil;
- /* We do want a lock here to avoid leaks */
- if (!defaultManager)
- defaultManager = [[VLCEventManager alloc] init];
+ if (defaultManager == nil)
+ @synchronized([VLCEventManager class]) {
+ defaultManager = [[VLCEventManager alloc] init];
+ }
return defaultManager;
}
--
1.7.12.4 (Apple Git-37)
More information about the vlc-devel
mailing list