HTL_thread_rwlock_wrlock
Applies a write lock to the RW lock.
Interface Definition
int HTL_thread_rwlock_wrlock(HTL_thread_rwlock_t *thread_rwlock);
Description
HTL_thread_rwlock_wrlock() is used to apply a write lock to the RW lock. If a success message is returned, the caller acquires the lock. If the RW lock has been acquired by another caller, the current caller is blocked until the RW lock is available. The RW lock can be acquired by only one writer.
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
thread_rwlock |
HTL_thread_rwlock_t * |
Address of the handle to the RW lock. |
Input |
Return Value
- HTL_THREAD_SUCCESS: success.
- Other values: failure. For details, see the error code descriptions.
Example
1 2 3 4 5 6 7 | HTL_thread_rwlock_t rwlock; ret = HTL_thread_rwlock_init(&rwlock, NULL); for (i = 0; i < 10; i++) { ret = HTL_thread_rwlock_wrlock(rwlock); ret = HTL_thread_rwlock_unlock(rwlock); } |
Parent topic: RW Lock Functions