Просмотр исходного кода

VLCKit: speedup message loop main thread delegate call

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Jörg Bleyel 11 лет назад
Родитель
Сommit
e18cc6a3f6
1 измененных файлов с 6 добавлено и 12 удалено
  1. 6 12
      Sources/VLCEventManager.m

+ 6 - 12
Sources/VLCEventManager.m

@@ -79,10 +79,6 @@ typedef enum
 }
 
 - (void)startEventLoop;
-
-- (void)callDelegateOfObjectAndSendNotificationWithArgs:(message_t *)message;
-- (void)callObjectMethodWithArgs:(message_t *)message;
-
 - (void)addMessageToHandleOnMainThread:(message_t *)message;
 
 @end
@@ -211,14 +207,12 @@ static void * EventDispatcherMainLoop(void * user_data)
 
             pthread_mutex_unlock(&_queueLock);
 
-            if (message.type == VLCNotification)
-                [self performSelectorOnMainThread:@selector(callDelegateOfObjectAndSendNotificationWithArgs:)
-                                       withObject:message
-                                    waitUntilDone: NO];
-            else
-                [self performSelectorOnMainThread:@selector(callObjectMethodWithArgs:)
-                                       withObject:message
-                                    waitUntilDone: YES];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                if (message.type == VLCNotification)
+                    [self callDelegateOfObjectAndSendNotificationWithArgs:message];
+                else
+                    [self callObjectMethodWithArgs:message];
+            });
         }
 
         /* Sleep a bit not to flood the interface */