我要评分
获取效率
正确性
完整性
易理解

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

1
2
3
4
5
6
7
8
    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);
    }