Skip navigation.
 
mlRe: NSMachPort thread safety
FROM : Adam R. Maxwell
DATE : Sun Mar 02 03:01:19 2008

On Mar 1, 2008, at 5:44 PM, Kyle Sluder wrote:

> On Sat, Mar 1, 2008 at 7:07 PM, Adam R. Maxwell <<email_removed>> 
> wrote:

>> 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

>
> You're misinterpreting "thread-safe"; you can't send messages to an
> NSPort on thread A from thread B.  Since each thread is only
> manipulating its own NSPort, you're in the clear.


Thanks, but I think you're misinterpreting the example :).  The object 
has a single NSMachPort ivar, added to the some thread's runloop. 
When a notification arrives on a different thread in 
processNotification:, it messages the NSMachPort.  When the port's 
delegate receives handleMachMessage: it processes the notification 
since it's guaranteed to be on the correct thread.

--
adam

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