Re: performSelectorOnMainThread and other thread notifications
Re: performSelectorOnMainThread and other thread notifications
- Subject: Re: performSelectorOnMainThread and other thread notifications
- From: Glen Low <email@hidden>
- Date: Fri, 13 Feb 2004 07:58:12 +0800
The secondary threads cannot be running an NSRunLoop since I don't
want to poll the kqueue, I want to block on it waiting for a file
system change (hmm.. unless NSRunLoops support such things). But if I
block waiting for a change, how will the main thread interrupt it,
say when a document is closed and no longer needs to be monitored?
NSRunLoops don't really poll, it blocks waiting on an event to come in
from one of its registered event sources and then check the sources as
needed. In other words it doesn't spin in a loop wasting CPU time.
Note almost all apps in Mac OS X have a run loop (NSRunLoop/CFRunLoop)
for its core event loop.
If you can get your kqueue attached as a source for the run loop you
could also attach a source (say an NSPort) that can be used to talk
with your secondary thread (while it is running the run loop). I need
to read up on kqueues myself so I cannot help you much and don't want
to go to far an mislead ya... so take what I am saying with a grain of
salt.
I realize NSRunLoops likely do not poll, although I would have to use
them in a polling fashion if I can't attach a kqueue as an event
source. As I understand it, NSPort is an abstraction of a Mach port?
Can I get some equivalence between a Mach port and a UNIX/BSD file
descriptor?
Originally I thought of opening an NSPipe from the main thread, and
passing the UNIX/BSD file descriptor for the read end to the kqueue
thread. Now kqueues can monitor file descriptors, so I could send
messages down the pipe. However Apple docs seem to say NSPipe is *not*
threadsafe. *sigh*...
"man kqueue" is pretty informative.
Cheers, Glen Low
---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.