cf_sem_try¶
Category: multithreading
GitHub: cute_multithreading.h
Attempts to decrement the semaphore's counter without sleeping, and returns success if decremented.
Parameters | Description |
---|---|
semaphore | The semaphore. |
Return Value¶
This function will not cause the thread to sleep if the semaphore's counter is zero. Instead, an error will be returned. Success is returned if the semaphore was successfully acquired and the counter was decremented.
Remarks¶
Since this function does not block/sleep, it allows the thread to continue running, even if the return value was an error. This lets a thread poll the semaphore instead of blocking/sleeping.
Related Pages¶
CF_Semaphore
cf_make_sem
cf_destroy_sem
cf_sem_post
cf_sem_value
cf_sem_wait