Implementing A "Future" (Cont.) The 'is value set' method is simple: /* check if the value in the given future is set. */ /* returns '0' on success, 0 otherwise. */ /* on success, '*is_set' is set to 1 if the future's */ /* value is set, '0' otherwise. */ int int_future_is_value_set(struct int_future* f, int* is_set) { int rc = -1; /* assume failure. */ if (!f || !is_set) { errno = EINVAL; goto int_future_is_value_set_ret; } if (pthread_mutex_lock(&f->mutex)) { *is_set = f->value_is_set; rc = 0; pthread_mutex_unlock(&f->mutex); } int_future_is_value_set_ret: return rc; }