Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - GCD check if queue is suspended

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 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?

like image 690
Duck Avatar asked Jan 31 '11 20:01

Duck


1 Answers

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.

like image 146
bbum Avatar answered Oct 16 '22 20:10

bbum