Oleg Krupnov <mailto:oleg.krup...@gmail.com> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to