Skip navigation.
 
mlNSMachPort thread safety
FROM : Adam R. Maxwell
DATE : Sun Mar 02 01:07:32 2008

Some time ago, I implemented a simple threaded notification queue by 
following the example here:

http://developer.apple.com/documentation/Cocoa/Conceptual/Notifications/Articles/Threading.html

which basically adds an NSMachPort to the thread's runloop and calls -
[NSPort sendBeforeDate:components:from:reserved:] to wake the thread 
up and allow it to process the enqueued notification.  The same 
technique has worked well for queuing invocations, also.  I recently 
noticed, however, that NSPort is explicitly listed as not being thread 
safe:

http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/chapter_950_section_2.html#/
/apple_ref/doc/uid/10000057i-CH12-SW4

Does this apply to NSMachPort as well?  I filed a doc bug hoping for 
eventual clarification, but I'd rather know sooner rather than later 
if the code has to be rewritten.  rdar://problem/5772256

Related mailsAuthorDate
mlNSMachPort thread safety Adam R. Maxwell Mar 2, 01:07
mlRe: NSMachPort thread safety Kyle Sluder Mar 2, 02:44
mlRe: NSMachPort thread safety Adam R. Maxwell Mar 2, 03:01
mlRe: NSMachPort thread safety Kyle Sluder Mar 2, 05:35
mlRe: NSMachPort thread safety Adam R. Maxwell Mar 2, 05:52