• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What is the runtime context of an event tap?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >What is the runtime context of an event tap? (From: Pat Wilson <email@hidden>)

  • Prev by Date: Re: Invalidated managed objects
  • Next by Date: Re: How do I get a file reference w/o relying on the path?
  • Previous by thread: What is the runtime context of an event tap?
  • Next by thread: How do I get a file reference w/o relying on the path?
  • Index(es):
    • Date
    • Thread