Re: NSRunLoop and NSNotification
Re: NSRunLoop and NSNotification
- Subject: Re: NSRunLoop and NSNotification
- From: Ondra Cada <email@hidden>
- Date: Thu, 8 Aug 2002 15:52:44 +0200
On Thursday, August 8, 2002, at 03:20 , Gregor Nobis wrote:
That's why I was wondering. I got a little confused because run loops are
thread-specific while the default notification center belongs to the
application.
That it does, but it always works in the scope of the current thread.
In other words, if it is posted style NOW, the appropriate observer
methods are just immediately called inside the thread in which the
notification was posted (effectively, it's almost the same as if the
posting method sent the appropriate messages directly). If it is posted
any other style though, observers are called by the runloop of the thread
inside which the notification was posted.
Caveat: that means in the I guess most common case when only main thread's
runloop runs, whilst all other threads are created just for background
computations, a notification from a background thread would be posted only
if posted style NOW (otherwise it would wait in the background thread's
runloop -- in vain, since the runloop does not run).
As for NSFileHandle, I regret to say I don't know which style it posts
(but I presume it would be ASAP, which would mean you have to have the
main run loop). Since they are multithreaded internally anyway, I see no
point in running its async services from a background thread though (and
thus there should be no problem: run them from the main thread, and the
notifications will be properly posted there, whatever style they use).
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.