GCDKit icon indicating copy to clipboard operation
GCDKit copied to clipboard

GCDQueue `suspend()` and `resume()`

Open peyton opened this issue 8 years ago • 1 comments

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 suspends 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 resumes. Doing so would break clients that keep references to the underlying dispatch queue.

peyton avatar Jun 27 '16 17:06 peyton

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?

JohnEstropia avatar Jun 30 '16 11:06 JohnEstropia