• 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: Threads and run loops
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threads and run loops


  • Subject: Re: Threads and run loops
  • From: James Bucanek <email@hidden>
  • Date: Fri, 5 Nov 2010 08:16:13 -0700

Oleg Krupnov <mailto:email@hidden> wrote (Friday, November 5, 2010 12:29 AM +0200):

1. What happens if I send a message via -performSelector:onThread:
from one thread to another, before the other thread has time to enter
its run loop? Is the message going to be lost?

The message invocation will wait in the run loop until it's consumed by the other thread.


Run loops are, essentially, a queue of events to be processed. "Running" a run loop really means nothing more than writing a loop that pulls events from the queue and processes them, one at a time.

Adding events to a run loop, and pulling them off to process them, are independent of one another. There's no requirement that you start pulling events off of a run loop before you can start pushing them. Your second thread can start running its "run loop" before you start pushing events, during, or after; it won't make any difference.

The only prerequisite is that the second run loop object exists (duh); this implies that the second thread must be first created so you have a run loop object to queue events on.

2. Is there a way to wait and make sure the thread has entered its run
loop? How do I check if a thread has entered its run loop?

NSConditionalLock

But unless you have some other specific need, you don't need it to synchronize with another run loop.

--
James Bucanek

_______________________________________________

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: 
 >Threads and run loops (From: Oleg Krupnov <email@hidden>)

  • Prev by Date: Re: NSDictionary casting
  • Next by Date: Re: Setting (not saving) NSPersistentDocument Metadata changes file Modification Date
  • Previous by thread: Re: Threads and run loops
  • Next by thread: NSDictionary casting
  • Index(es):
    • Date
    • Thread