JNF performOnMainThreadWaiting thread safety
Mike Swingler
swingler at apple.com
Tue Feb 19 08:42:00 PST 2013
On Feb 18, 2013, at 5:22 PM, Leonid Romanov <leonid.romanov at oracle.com> wrote:
> Hi,
> I've got a question: is + (void)performOnMainThreadWaiting:(BOOL)waitUntilDone withBlock:(void (^)())block thread safe? Suppose two native threads are calling this method with waitUntilDone set to YES. Should we be OK in this case or some external locking is necessary to ensure that both threads won't call performOnMainThreadWaiting at the "same" time?
+[JNFRunLoop performOnMainThreadWaiting:withBlock:] is completely thread safe. That is somewhat the point - and yes, it is implemented in terms of -[NSObject performSelectorOnMainThread:withObject:waitUntilDone:modes:], to ensure that the block is run in the proper run loop modes.
Regards,
Mike Swingler
Apple Inc.
More information about the macosx-port-dev
mailing list