HTL_thread_mutex_trylock
Attempts to lock a mutex.
Interface Definition
int HTL_thread_mutex_trylock(HTL_thread_mutex_t *thread_mutex);
Description
HTL_thread_mutex_trylock() attempts to lock the mutex thread_mutex. If HTL_THREAD_SUCCESS is returned, the caller acquires the mutex. If the caller fails to acquire the lock, HTL_THREAD_ERR_MUTEX_LOCKED is returned. If thread_mutex is recursive, the same caller can obtain multi-level ownership of the mutex. thread_mutex remains locked until it is unlocked as many times as the ownership level.
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
thread_mutex |
HTL_thread_mutex_t * |
Address of the handle to the mutex. |
Input |
Return Value
- HTL_THREAD_SUCCESS: success.
- Other values: failure. For details, see the error code descriptions.
Example
1 2 | ret = HTL_thread_mutex_trylock(&mutex); if ( ret != HTL_THREAD_SUCCESS) return; |
Parent topic: Mutex Functions