struct dispatch_object_s *prev, *head = _head._do, *tail = _tail._do;
tail->do_next = NULL;
+ _dispatch_retain(dq);
prev = fastpath(dispatch_atomic_xchg(&dq->dq_items_tail, tail));
if (prev) {
// if we crash here with a value less than 0x1000, then we are at a known bug in client code
dq->dq_items_head = head;
_dispatch_wakeup(dq);
}
+ _dispatch_release(dq);
}
#define _dispatch_queue_push(x, y) _dispatch_queue_push_list((x), (y), (y))
#if DISPATCH_DEBUG
dispatch_debug(ds, __FUNCTION__);
#endif
+ // Right after we set the cancel flag, someone else
+ // could potentially invoke the source, do the cancelation,
+ // unregister the source, and deallocate it. We would
+ // need to therefore retain/release before setting the bit
+
+ _dispatch_retain(ds);
dispatch_atomic_or(&ds->ds_atomic_flags, DSF_CANCELED);
_dispatch_wakeup(ds);
+ _dispatch_release(ds);
}
#ifndef DISPATCH_NO_LEGACY