Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kqueue on OS X



On Feb 17, 2004, at 6:01 PM, Glen Low wrote:
Now pipes and file descriptors seem dangerous to me, since they are not necessarily threadsafe (especially with Cocoa)

Now, this is definitely not true. Two threads should be able to talk to each other on opposite ends of the same pipe without problem. And Cocoa doesn't have to enter the picture - you can use the raw system calls.

Here's some code that does a similar thing:

<http://www.slamb.org/svn/repos/projects/objc/SLDescriptorNotifier.h>
<http://www.slamb.org/svn/repos/projects/objc/SLDescriptorNotifier.m>

I wrote it in a moment of stupidity - it notifies an NSRunLoop of changes on file descriptors, and of course CFSocket does the same thing more easily. (I was apparently looking at an older version of the docs or something, in which CFSocket didn't support write notifications...I don't know.) In any case, it is in a very similar situation; I used a raw pipe to wake it up when necessary, an NSMachPort to wake the main thread (though an NSMessagePort might be better), and an NSRecursiveLock to ensure safety.

Good luck.

Scott Lamb
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: kqueue on OS X (From: Glen Low <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.