cp_hashtable_lock(3) - Linux man page
Name
cp_hashtable_lock, cp_hashtable_unlock, cp_hashtable_rd_lock, cp_hashtable_wrlock - hashtable locking functions
Synopsis
#include <cprops/hashtable.h>
int cp_hashtable_lock(cp_hashtable *table, int type);
int cp_hashtable_unlock(cp_hashtable *table);
int cp_hashtable_rdlock(cp_hashtable *table);
int cp_hashtable_wrlock(cp_hashtable *table);
Description
cp_hashtable_lock attempts a lock of the type given in type. Possible lock types are
COLLECTION_LOCK_READ, which allows other threads to read concurrently, COLLECTION_LOCK_WRITE, which grants exclusive access or
COLLECTION_LOCK_NONE which has no effect. Unless COLLECTION_MODE_NOSYNC is set, single table operations are synchronized and do not require explicit
locking. Explicit locking is required for transaction-like operations where several table operations must complete as a group before allowing other threads to
access the table. Once a thread has obtained the table lock, subsequent table operations on this thread will not attempt to perform additional locking, but
will attempt locking on other threads. The application is responsible for performing the correct type of locking - if any changes may be made to table content,
the table must be locked for writing; Otherwise it may be locked for reading.
cp_hashtable_unlock releases a lock previously acquired with cp_hashtable_lock.
cp_hashtable_rdlock and cp_hashtable_wrlock are the same as calling cp_hashtable_lock with COLLECTION_LOCK_READ and
COLLECTION_LOCK_WRITE respectively.
Return Value
locking functions return 0 on success or a non-zero error code on failure.
Errors
- EINVAL
- the table was instantiated with COLLECTION_MODE_NOSYNC or an invalid lock type code was given.
Other error codes may be returned from the underlying synchronization api.
See Also
pthread_rwlock_rdlock(3), pthread_rwlock_wrlock(3), cp_hashtable(3)