Re: Questions about [NSApplication run]
Re: Questions about [NSApplication run]
- Subject: Re: Questions about [NSApplication run]
- From: Scott Ribe <email@hidden>
- Date: Sat, 06 Dec 2008 10:11:53 -0600
- Thread-topic: Questions about [NSApplication run]
What about spawning a secondary thread which uses select (or kqueue, which
is pretty easy to use BTW) to block waiting for events, without a timeout.
When select (or kqueue) returns an event(s), then use:
[yourAppDelegateOrControllerOrWhatever performSelectorOnMainThread:
@selector(handleFactorEvent:) withObject: yourCustomEventDescriptorClass
waitUntilDone: NO]
That's the simple version. In my own code, the bg thread actually invokes in
the bg thread a method on my app delegate that creates the event instance
and puts the event on a queue (std::vector<mythingy> with appropriate
locking) before calling performSelectorOnMainThread which will pull events
out of the queue until there are no more. And... I don't rememeber why ;-)
--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden