GCDKit
GCDKit copied to clipboard
GCDQueue `suspend()` and `resume()`
Hey, this PR adds thin wrappers for dispatch_suspend
and dispatch_resume
to GCDQueue
.
One gotcha with dispatch_suspend
is that it must be balanced with a call to dispatch_resume
before the queue is deallocated. If we want, we can handle unbalanced suspend
s for the user with a thin class wrapper for custom queues that tracks suspend
count and, on deinit
, submits a barrier block to the target queue balancing resume
s. Doing so would break clients that keep references to the underlying dispatch queue.
Thanks for the pull request!
Hmm... GCDKit used to have this but I removed it because it's confusing; it only works on custom queues: https://github.com/JohnEstropia/GCDKit/commit/eff3b65633869f485ff07ce961bad4e4b9e41a40
If we're to bring it back it should be decided how to handle global queues which does not allow suspending at all. Should we raise a fatal error/assertion? Should we fail silently?