Re: What is the runtime context of an event tap?
Re: What is the runtime context of an event tap?
- Subject: Re: What is the runtime context of an event tap?
- From: Ken Thomases <email@hidden>
- Date: Sat, 3 Apr 2010 17:43:22 -0500
On Apr 3, 2010, at 5:16 PM, Pat Wilson wrote:
> When an event tap is created using CGEventTapCreate, which process, or thread actually runs the callback function? The one which created the tap, the first responder, ...?
The first responder isn't a thread, process, or runtime/execution context. That aspect of your question doesn't make any sense, just so you know.
The documentation for CGEventTapCreate says:
> Your callback function is invoked from the run loop to which the event tap is added as a source. The thread safety of the callback is defined by the run loop’s environment.
Since a run loop is directly associated to a thread, you control which thread the callback is called on. If you add the run loop source for the returned Core Foundation mach port to the current run loop, then the callback will be called on the current thread. If you add it to the main run loop, then it will be called on the main thread. Etc.
Regards,
Ken
_______________________________________________
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