On 19/10/2005 01:32 Am, Scott Fraser wrote:
> On Oct 19, 2005, at 12:27 PM, Mike Kluev wrote:
>>
>> Neither ReceiveNextEvent nor SendEventToEventTarget are thread
>> safe, see below.
>
> In my copy of CarbonEventsCore.h (Version: HIToolBox-219.4.81~2),
> ReceiveNextEvent is marked as "Thread safe". You're right about
> "SendEventToEventTarget". See Eric's posts correcting my other
> mistakes.
Now this makes sense. Thanks. Also thanks to David Duncan who
pointed this out as well. In HIToolbox-145.33~1 (corresponding
to 10.3, the latest I have here) it is marked "Not Thread Safe",
thus the confusion. The question remains: was it just a
documentation bug or did something in implementation change to
make ReceiveNextEvent thread safe?
Speculation:
"Carbon Events" consists of two halves. The lower half deals with
eventRefs, eventQueues, eventLoops, eventTimers and corresponding
APIs like CreateEvent, SetEventParameter, GetCurrentEventQueue,
PostEventToQueue, ReceiveNextEvent, etc. Basically this is just
wrappers above the corresponding CF stuff.
The higher half is different; it introduces eventHandlers,
eventTargets, event handlers' stack and corresponding APIs like
GetFooEventTarget, InstallEventHandler, SendEventToEventTarget,
CallNextEventHandler, etc. All the beauty of having events being
automatically dispatched to appropriate targets is in the higher
half.
Lower half is thread safe or conditionally thread safe.
Higher half is not thread safe (whom to blame for this? Ed? :-)
Lower half is independent and doesn't know about the higher half
(no more wonder why RunCurrentEventLoop doesn't dispatch events).
The split between two halves could have been more obvious if the
lower half was fully in CarbonEventsCore.h and the higher half
fully in CarbonEvents.h, but it is not that straight
(SendEventToEventTarget while being the "higher half" API is in
CarbonEventsCore.h). Distinguishing these two halves and keeping
them mentally separately helps understanding why events handlers'
stack (the higher half concepts) and SendEventToEventTarget in
particular are not thread safe and why ReceiveNextEvent (the
lower half concept) should be thread safe even if it was
documented thread unsafe.
End of speculation. Corrections appreciated :)
Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden
This email sent to email@hidden