Guest User

Untitled

a guest
Jun 21st, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. // this source is in the public domain
  2. #import "semaphore_scope.h"
  3.  
  4. dispatch_semaphore_t foo_dsem_; // initialized elsewhere
  5.  
  6. int foo() {
  7. DSemaphoreScope semscope(foo_dsem_);
  8. // critical section
  9. if (!something) {
  10. return 0;
  11. // dispatch_semaphore_signal implicitly called before returning
  12. }
  13. // do something else here maybe
  14. return 1;
  15. // dispatch_semaphore_signal implicitly called before returning
  16. }
Add Comment
Please, Sign In to add comment