Implementing A "Future" (Cont.) if (pthread_mutex_lock(&f->mutex) != 0) goto int_future_wait_for_value_mutex_fail; /* wait for value to be set. */ while (!f->value_is_set) { pthread_cond_wait(&f->cond, &f->mutex); } /* value is set. give it to the caller. */ *value = f->value; rc = 0; pthread_mutex_unlock(&f->mutex); goto int_future_wait_for_value_ret; int_future_wait_for_value_mutex_fail: int_future_wait_for_value_ret: return rc; }