[libdispatch-dev] Canceling/releasing a suspended timer

Kevin Van Vechten kvv at apple.com
Tue Dec 14 16:06:36 PST 2010

The crash you're seeing is actually an assertion. Dispatch objects must be fully resumed before the final release, this is so that the object can navigate through the internal machinery to properly cancel, etc.

I think the order of operations you're looking for is:

dispatch_source_cancel(source);	// ATOMIC ; this guarantees the event handler will not fire again after the source is resumed

Hope this helps,


On Dec 14, 2010, at 3:33 PM, Kevin Wojniak wrote:

> It appears that releasing a suspended timer is not allowed and will crash. Also, canceling the suspended timer does not appear to work and call the cancel handler. Are these correct assumptions? If so, then if I have a suspended timer, is the proper way to cancel or release it is to first resume? However I would imagine there is still the off chance that the timer could fire in between those calls to resume and cancel, requiring a flag to be set.
> Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-dev/attachments/20101214/69b4dc96/attachment.html>

More information about the libdispatch-dev mailing list