Advertisement
Guest User

Untitled

a guest
Sep 28th, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
  2. {
  3. /* Check first for speed */
  4. if (once_control->state == PTHREAD_NEEDS_INIT) {
  5. pthread_mutex_lock(&(once_control->mutex));
  6. if (once_control->state == PTHREAD_NEEDS_INIT) {
  7. init_routine();
  8. once_control->state = PTHREAD_DONE_INIT;
  9. }
  10. pthread_mutex_unlock(&(once_control->mutex));
  11. }
  12. return(OK);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement