Re: Notifications on main thread
Re: Notifications on main thread
- Subject: Re: Notifications on main thread
- From: James Bucanek <email@hidden>
- Date: Tue, 2 Nov 2010 11:44:00 -0700
Jonny Taylor <mailto:email@hidden> wrote (Tuesday,
November 2, 2010 11:07 AM -0000):
Empirically that does seem to behave in a common sense manner. However, if we
examine the wording of the release note I believe it is explicitly stating
that this should NOT be relied on - i.e. posting a notification from a
selector on the main thread does not guarantee that the registered
notification callbacks will be executed on the main thread. The release notes
state [my emphasis]:
Notifications can be posted by any given queue ON A DIFFERENT THREAD THAN
THE THREAD THE QUEUE IS A DEFAULT QUEUE FOR (when a queue is
a default queue for some thread);
...
I agree with you that the approach you and I are talking about seems to work
in practice, and certainly seems like a logical approach, but somebody at
Apple seems to have taken the time to write an obscure release note
specifically discouraging such an approach.
Jonny,
I think you're reading too much into the statement made in the
release nodes. If we assume that notifications are posted from
the thread they are _enqueued_ from, then the wording of the
release note is absolutely correct. It's a warning for those who
would (rightfully, in my mind) assume that the notification
would be posted in the thread associated with the run loop that
the queue is connected to.
What this footnote does NOT say is "Warning, your notification
will be posted via some random thread that you have no control
over," which is how I think some people are interpreting it.
I think this is because the release note is written from the
perceptive of the queue. From the queue's perspective,
notifications could be executed from any thread. But from the
perspective of the enqueuer, the notification is always posted
in its thread.
I think it's clear from the document that notifications
ARE posted from the thread that ENQUEUES the notification,
NOT the thread that OWNS the queue's run loop.
If you don't think that the documentation is clear about this
point, file a documentation enhancement request. I've filed
requests like this in the past, and have been almost universally
reworded with improved documentation.
James
--
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