[libdispatch-dev] Canceling/releasing a suspended timer

Kevin Wojniak kainjow at kainjow.com
Wed Dec 15 11:57:11 PST 2010

Thanks Kevin, that works.

On Dec 14, 2010, at 4:06 PM, Kevin Van Vechten wrote:

> 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
> dispatch_resume(source);
> dispatch_release(source);
> Hope this helps,
> Kevin
> 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

More information about the libdispatch-dev mailing list