<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hello all,</div><div><br></div><div><span style="white-space: inherit; line-height: 17.804800033569336px;">performSelectorOnMainThread is not state of the art and slower than </span>dispatch_async<span style="line-height: 17.804800033569336px; white-space: inherit;">.</span></div><div><br></div><div><div>---</div><div> Sources/VLCEventManager.m | 39 ++++++++++-----------------------------</div><div> 1 file changed, 10 insertions(+), 29 deletions(-)</div><div><br></div><div>diff --git a/Sources/VLCEventManager.m b/Sources/VLCEventManager.m</div><div>index 65d8007..e9384f4 100644</div><div>--- a/Sources/VLCEventManager.m</div><div>+++ b/Sources/VLCEventManager.m</div><div>@@ -79,10 +79,6 @@ typedef enum</div><div> }</div><div> </div><div> - (void)startEventLoop;</div><div>-</div><div>-- (void)callDelegateOfObjectAndSendNotificationWithArgs:(message_t</div><div>-*)message;</div><div>-- (void)callObjectMethodWithArgs:(message_t *)message;</div><div> - (void)callDelegateOfObject:(id)aTarget withDelegateMethod:(SEL)aSelector</div><div> withNotificationName:(NSString *)aNotificationName;</div><div> - (pthread_cond_t *)signalData;</div><div>@@ -219,14 +215,16 @@ static void * EventDispatcherMainLoop(void * user_data)</div><div> </div><div>             pthread_mutex_unlock([self queueLock]);</div><div> </div><div>-            if (message.type == VLCNotification)</div><div>-                [self performSelectorOnMainThread:@selector(callDelegateOfObjectAndSendNotificationWithArgs:)</div><div>-                                       withObject:message</div><div>-                                    waitUntilDone: NO];</div><div>-            else</div><div>-                [self performSelectorOnMainThread:@selector(callObjectMethodWithArgs:)</div><div>-                                       withObject:message</div><div>-                                    waitUntilDone: YES];</div><div>+            dispatch_async(dispatch_get_main_queue(), ^{</div><div>+                if ([self markMessageHandledOnMainThreadIfExists:message]) {</div><div>+                    if (message.type == VLCNotification) {</div><div>+                        [self callDelegateOfObject:message.target withDelegateMethod:message.sel withNotificationName:message.name];</div><div>+                    } else {</div><div>+                        void (*method)(id, SEL, id) = (void (*)(id, SEL, id))[message.target methodForSelector: message.sel];</div><div>+                        method(message.target, message.sel, message.object);</div><div>+                    }</div><div>+                }</div><div>+            });</div><div>         }</div><div>     }</div><div> }</div><div>@@ -310,23 +308,6 @@ static void * EventDispatcherMainLoop(void * user_data)</div><div>     return !cancelled;</div><div> }</div><div> </div><div>-- (void)callDelegateOfObjectAndSendNotificationWithArgs:(message_t *)message</div><div>-{</div><div>-    // Check that we were not cancelled, ie, target was released</div><div>-    if ([self markMessageHandledOnMainThreadIfExists:message])</div><div>-        [self callDelegateOfObject:message.target withDelegateMethod:message.sel withNotificationName:message.name];</div><div>-</div><div>-}</div><div>-</div><div>-- (void)callObjectMethodWithArgs:(message_t *)message</div><div>-{</div><div>-    // Check that we were not cancelled</div><div>-    if ([self markMessageHandledOnMainThreadIfExists:message]) {</div><div>-        void (*method)(id, SEL, id) = (void (*)(id, SEL, id))[message.target methodForSelector: message.sel];</div><div>-        method(message.target, message.sel, message.object);</div><div>-    }</div><div>-}</div><div>-</div><div> - (void)callDelegateOfObject:(id)aTarget withDelegateMethod:(SEL)aSelector withNotificationName:(NSString *)aNotificationName</div><div> {</div><div>     [[NSNotificationCenter defaultCenter] postNotification: [NSNotification notificationWithName:aNotificationName object:aTarget]];</div><div>-- </div><div>1.8.5.2 (Apple Git-48)</div><div><br></div></div><div><br></div><div><br></div><div>RG</div><div>Jörg</div><div style="color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;"><br></div><span id="OLK_SRC_BODY_SECTION" style="color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;"><div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"><span style="font-weight:bold">Von: </span> Florent Pillet <<a href="mailto:fpillet@gmail.com">fpillet@gmail.com</a>><br><span style="font-weight:bold">Antworten an: </span> Mailing list for VLC media player developers <<a href="mailto:vlc-devel@videolan.org">vlc-devel@videolan.org</a>><br><span style="font-weight:bold">Datum: </span> Freitag, 11. Juli 2014 11:16<br><span style="font-weight:bold">An: </span> Mailing list for VLC media player developers <<a href="mailto:vlc-devel@videolan.org">vlc-devel@videolan.org</a>><br><span style="font-weight:bold">Betreff: </span> Re: [vlc-devel] [PATCH 5/9] VLCKit: There is no reason to have a blocking call to main thread from the event manager thread<br></div><div><br></div><div dir="ltr">Yes the execution order is guaranteed if we always push calls to another thread the same way (either using dispatch or -performSelector). There is no need to wait for execution completion, IMHO.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 11 July 2014 08:20, Gleb Pinigin <span dir="ltr"><<a href="mailto:gpinigin@gmail.com" target="_blank">gpinigin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi,<br><br>
Yep, most likely.<br><br>
Do you see a real reason to make this call synchronous?<br><div class="HOEnZb"><div class="h5"><br>
On Jul 11, 2014, at 1:13 PM, David Fuhrmann <<a href="mailto:david.fuhrmann@gmail.com">david.fuhrmann@gmail.com</a>> wrote:<br><br>
><br>
> Am 11.07.2014 um 04:08 schrieb Gleb Pinigin <<a href="mailto:gpinigin@gmail.com">gpinigin@gmail.com</a>>:<br>
><br>
>><br>
>> It's only needed to guarantee that events will be performed on main thread in dispatch order.<br>
><br>
> Hi,<br>
><br>
> Even with waitUntilDone: NO, the execution order on the main thread should be retained, no?<br>
><br>
> With best regards,<br>
> David<br>
> _______________________________________________<br>
> vlc-devel mailing list<br>
> To unsubscribe or modify your subscription options:<br>
> <a href="https://mailman.videolan.org/listinfo/vlc-devel" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Florent Pillet<br><br></div>
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
<a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a>
</span></body></html>