Closed peyton closed 1 year ago
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?
Hey, this PR adds thin wrappers for
dispatch_suspend
anddispatch_resume
toGCDQueue
.One gotcha with
dispatch_suspend
is that it must be balanced with a call todispatch_resume
before the queue is deallocated. If we want, we can handle unbalancedsuspend
s for the user with a thin class wrapper for custom queues that trackssuspend
count and, ondeinit
, submits a barrier block to the target queue balancingresume
s. Doing so would break clients that keep references to the underlying dispatch queue.