• 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: Context in GCD source cancel handler?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Context in GCD source cancel handler?


  • Subject: Re: Context in GCD source cancel handler?
  • From: Dave Zarzycki <email@hidden>
  • Date: Wed, 05 Jan 2011 11:15:48 -0800

Jonathon,

GCD is an object oriented API done in C. If you look at the man page entitled dispatch_object, you'll see that one can call dispatch_set_context() and dispatch_get_context() against any GCD object (sources and queues are where they make the most sense). In fact, if you're simply looking for a "goodbye kiss" when the last reference to a GCD object is dropped (via dispatch_retain() and dispatch_release()), then your code can install a finalizer via dispatch_set_finalizer_f(), which is passed the same context managed by the aforementioned API.

Have fun,

davez


On Jan 5, 2011, at 10:58 AM, Jonathon Kuo wrote:

> When a GCD source gets cancelled, either via dispatch_source_cancel() or because the source went away, I have no context other than the dispatch_source_t source variable. How can I know for which source a source cancel handler gets invoked? I have many simultaneous sources (sockets, files, etc) and when a source cancel handler gets called I have no idea what source it's for, so I can't do cleanup. Is dispatch_source_t queryable? Is there a way to attach a userInfo object to it? Do I have to manage this externally in a table myself?_______________________________________________
>
> 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

_______________________________________________

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

  • Follow-Ups:
    • Re: Context in GCD source cancel handler?
      • From: Jonathon Kuo <email@hidden>
References: 
 >Context in GCD source cancel handler? (From: Jonathon Kuo <email@hidden>)

  • Prev by Date: [Solved] Re: When adding Cocoa classes I get a lot of compile errors automatically
  • Next by Date: execute system("some script") on behalf of root from non-root app
  • Previous by thread: Context in GCD source cancel handler?
  • Next by thread: Re: Context in GCD source cancel handler?
  • Index(es):
    • Date
    • Thread