HTL_thread_rwlock_rdlock
Applies a read lock to the RW lock.
Interface Definition
int HTL_thread_rwlock_rdlock(HTL_thread_rwlock_t *thread_rwlock);
Description
HTL_thread_rwlock_rdlock() is used to apply a read lock to the RW lock. If a success message is returned, the caller acquires the lock. If the RW lock has been acquired by a writer, the caller is blocked until the RW lock is available. thread_rwlock can be acquired by multiple readers.
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
ret = HTL_thread_rwlock_init(&rwlock, NULL);
for (j = 0; j < 10; j++) {
ret = HTL_thread_rwlock_rdlock(&rwlock);
}
for (j = 0; j < 10; j++) {
ret = HTL_thread_rwlock_unlock(&rwlock);
}
Parent topic: RW Lock Functions