cp_narytree
Section: libcprops - cp_narytree (3)
Updated: SEPTEMBER 2006
Index
Return to Main Contents
NAME
cp_narytree_lock, cp_narytree_rdlock, cp_narytree_wrlock,
cp_narytree_unlock - acquire / release a lock on an N-ary tree
SYNOPSIS
#include <cprops/nary.h>
int cp_narytree_lock(cp_narytree *tree, int type);
int cp_narytree_rdlock(cp_narytree *tree);
int cp_narytree_wrlock(cp_narytree *tree);
int cp_narytree_unlock(cp_narytree *tree);
cp_narytree_lock
locks the tree for reading if
type
is
COLLECTION_LOCK_READ
or for writing if
type
is COLLECTION_LOCK_WRITE. The tree mode may not have
COLLECTION_MODE_NOSYNC
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.
Calls to
cp_narytree_lock
must be coupled with calls to
cp_narytree_unlock
after the operation is completed.
cp_narytree_rdlock(tree)
is a synonym for cp_narytree_lock(tree, COLLECTION_LOCK_READ).
is a synonym for cp_narytree_lock(tree, COLLECTION_LOCK_WRITE).
RETURN VALUE
cp_narytree_lock,
cp_narytree_rdlock
and
cp_narytree_wrlock
return 0 on success, EINVAL if COLLECTION_MODE_NOSYNC is set or -1 if locking
fails.
cp_narytree_unlock
returns 0 on success or -1 if unlocking fails.
SEE ALSO
cp_narytree_set_mode(3),
cp_narytree_insert(3)
Index
- NAME
-
- SYNOPSIS
-
- cp_narytree_lock
-
- RETURN VALUE
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 17:58:11 GMT, September 08, 2006
|
|