cp_hashtable

Section: libcprops - cp_hashtable (3)
Updated: OCTOBER 2005
Index Return to Main Contents
 

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)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 12:01:45 GMT, May 23, 2006
SourceForge.net Logo