20#define RBT_NODE_ROOT_T RBT_TOKEN_2_W(RBT_NODE_H_PREFIX_, node_root_t)
80 root.
mutex = PTHREAD_MUTEX_INITIALIZER;
81 root.
cond = PTHREAD_COND_INITIALIZER;
112#undef RBT_NODE_ROOT_READ
113#define RBT_NODE_ROOT_READ(root, func, ...) \
114pthread_mutex_lock(&(root.mutex)); \
115while (root.writers) \
117 pthread_cond_wait(&(root.cond), &(root.mutex)); \
120pthread_mutex_unlock(&(root.mutex)); \
121func(root.node, ##__VA_ARGS__); \
122pthread_mutex_lock(&(root.mutex)); \
126 pthread_cond_signal(&(root.cond)); \
128pthread_mutex_unlock(&(root.mutex))
156#undef RBT_NODE_ROOT_WRITE
157#define RBT_NODE_ROOT_WRITE(root, func, ...) \
158pthread_mutex_lock(&(root.mutex)); \
160while (root.readers) \
162 pthread_cond_wait(&(root.cond), &(root.mutex)); \
164func(root.node, ##__VA_ARGS__); \
166pthread_cond_signal(&(root.cond)); \
167pthread_mutex_unlock(&(root.mutex))
171#ifdef RBT_NODE_CACHE_SIZE
175#undef RBT_NODE_CACHE_MUTEX
176#define RBT_NODE_CACHE_MUTEX RBT_TOKEN_2_W(RBT_NODE_H_PREFIX_, node_cache_mutex)
184pthread_mutex_t RBT_NODE_CACHE_MUTEX = PTHREAD_MUTEX_INITIALIZER;
189#undef RBT_NODE_CACHE_LOCK
190#define RBT_NODE_CACHE_LOCK pthread_mutex_lock(&RBT_NODE_CACHE_MUTEX)
195#undef RBT_NODE_CACHE_UNLOCK
196#define RBT_NODE_CACHE_UNLOCK pthread_mutex_unlock(&RBT_NODE_CACHE_MUTEX)
RBT_NODE_T * RBT_NODE_CREATE(RBT_PIN_T *key, RBT_KEY_SIZE_T bits, RBT_VALUE_T value, RBT_NODE_T *left, RBT_NODE_T *right)
Create a node.
Definition: node.h:1082
RBT_NODE_ROOT_T RBT_NODE_NEW()
Create a new root node.
Definition: node_pthread.h:76
struct RBT_NODE_ROOT_T RBT_NODE_ROOT_T
Definition: node_pthread.h:30
unsigned int writers
The number of queued write operations.
Definition: node_pthread.h:47
pthread_mutex_t mutex
The mutex that protects this root node.
Definition: node_pthread.h:53
RBT_NODE_T * node
The root node.
Definition: node_pthread.h:35
pthread_cond_t cond
The condition variable used to signal waiting threads.
Definition: node_pthread.h:59
unsigned int readers
The number of concurrent read operations.
Definition: node_pthread.h:41
Rabbit Tree node type.
Definition: node.h:420