• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Questions about [NSApplication run]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Questions about [NSApplication run] (From: "Slava Pestov" <email@hidden>)

  • Prev by Date: Document package
  • Next by Date: JSON Framework
  • Previous by thread: Re: Questions about [NSApplication run]
  • Next by thread: secure dns resolution
  • Index(es):
    • Date
    • Thread