Example #1
0
bool_t
Lock_obtain(Lock *self) {
    int32_t time_left = self->interval == 0 ? 0 : self->timeout;
    bool_t locked = Lock_Request(self);

    while (!locked) {
        time_left -= self->interval;
        if (time_left <= 0) { break; }
        Sleep_millisleep(self->interval);
        locked = Lock_Request(self);
    }

    if (!locked) { ERR_ADD_FRAME(Err_get_error()); }
    return locked;
}
Example #2
0
bool
Lock_Obtain_IMP(Lock *self) {
    LockIVARS *const ivars = Lock_IVARS(self);
    int32_t time_left = ivars->interval == 0 ? 0 : ivars->timeout;
    bool locked = Lock_Request(self);

    while (!locked) {
        time_left -= ivars->interval;
        if (time_left <= 0) { break; }
        Sleep_millisleep(ivars->interval);
        locked = Lock_Request(self);
    }

    if (!locked) { ERR_ADD_FRAME(Err_get_error()); }
    return locked;
}