Section: libcprops - cp_rbtree (3)
Updated: MAY 2006
Return to Main Contents
cp_rbtree_lock, cp_rbtree_rdlock, cp_rbtree_wrlock,
cp_rbtree_unlock - acquire / release a lock on an red-black tree
int cp_rbtree_lock(cp_rbtree *tree, int type);
int cp_rbtree_rdlock(cp_rbtree *tree);
int cp_rbtree_wrlock(cp_rbtree *tree);
int cp_rbtree_unlock(cp_rbtree *tree);
locks the tree for reading if
or for writing if
is COLLECTION_LOCK_WRITE. The tree mode may not have
set prior to locking. Explicit locking isn't required for single tree
operations (insertion, retrieval, deletion) which perform locking on their own
but rather for transaction-like operations. To prevent other threads from
accessing the tree while performing a series of mapping insertion, removal and
lookup operations, the tree must be explicitly locked first. Tree operation
functions will not attempt locking if the current thread owns the tree lock.
This prevents deadlocks but leaves the responsibility for using the correct
kind of locking with the application: if there's any possibility the
application could change the tree structure in the transaction (ie insert or
remove a mapping), the tree must be write locked. If the transaction consists
of lookups only, the tree may be read locked.
must be coupled with calls to
after the operation is completed.
is a synonym for cp_rbtree_lock(tree, COLLECTION_LOCK_READ).
is a synonym for cp_rbtree_lock(tree, COLLECTION_LOCK_WRITE).
return 0 on success, EINVAL if COLLECTION_MODE_NOSYNC is set or -1 if locking
returns 0 on success or -1 if unlocking fails.
- RETURN VALUE
- SEE ALSO
This document was created by
using the manual pages.
Time: 10:00:49 GMT, May 30, 2006