开发者

iPhone - GCD check if queue is suspended

开发者 https://www.devze.com 2023-02-07 14:57 出处:网络
I have to use dispatch_resume(...); to resume a dispatch that was suspended, but as the method resuming the dispatch may be called by several parts of the app, I need to know if the dispatch is suspen

I have to use dispatch_resume(...); to resume a dispatch that was suspended, but as the method resuming the dispatch may be called by several parts of the app, I need to know if the dispatch is suspended开发者_如何学Python before calling it to resume (the docs says I have to balance dispatch resume/suspend and cannot have more resumes than suspends, or I will end with a "negative suspension counter".

Is there a way to do test if a dispatch is suspended?


There is not, by design (and just like there is no cancellation mechanism). The notion of suspend/resume must be balanced every bit as carefully as retain/release

That is, if A suspends the queue, there is no way for B to safely know that it can resume the queue without intimate knowledge of A. Given that, there is no reason for the dispatch APIs to add the complexity of is-suspended queries and enable a whole class of bugs that would crop up all over the place.

0

精彩评论

暂无评论...
验证码 换一张
取 消