YAZ
5.34.0
|
Header for Mutex functions. More...
Go to the source code of this file.
Typedefs | |
typedef struct yaz_mutex * | YAZ_MUTEX |
YAZ MUTEX opaque pointer. More... | |
typedef struct yaz_cond * | YAZ_COND |
YAZ condition opaque pointer. More... | |
Functions | |
void | yaz_mutex_create (YAZ_MUTEX *mutexp) |
create MUTEX More... | |
void | yaz_mutex_enter (YAZ_MUTEX mutex) |
enter critical section / AKA lock More... | |
void | yaz_mutex_leave (YAZ_MUTEX mutex) |
leave critical section / AKA unlock More... | |
void | yaz_mutex_destroy (YAZ_MUTEX *mutexp) |
destroy MUTEX More... | |
void | yaz_mutex_set_name (YAZ_MUTEX mutex, int log_level, const char *name) |
sets name of MUTEX for debugging purposes More... | |
void | yaz_cond_create (YAZ_COND *p) |
creates condition variable More... | |
void | yaz_cond_destroy (YAZ_COND *p) |
destroys condition variable More... | |
int | yaz_cond_wait (YAZ_COND p, YAZ_MUTEX m, const struct timeval *abstime) |
waits for condition More... | |
int | yaz_cond_signal (YAZ_COND p) |
unblock one thread waiting for block More... | |
int | yaz_cond_broadcast (YAZ_COND p) |
unblock all threads waiting for block More... | |
Header for Mutex functions.
Definition in file mutex.h.
int yaz_cond_broadcast | ( | YAZ_COND | p | ) |
void yaz_cond_create | ( | YAZ_COND * | p | ) |
void yaz_cond_destroy | ( | YAZ_COND * | p | ) |
int yaz_cond_signal | ( | YAZ_COND | p | ) |
waits for condition
p | condition variable handle |
m | mutex |
abstime | wait until this time; 0 for indefinite wait |
Semantics like pthread_cond_wait.
Definition at line 75 of file condvar.c.
References yaz_gettimeofday().
void yaz_mutex_create | ( | YAZ_MUTEX * | mutexp | ) |
create MUTEX
mutexp | is pointer to MUTEX handle (*mutexp must be NULL) |
It is important that *mutexp is NULL. If not, yaz_mutex_create will not modify the handle (assumes it is already created!)
Definition at line 43 of file mutex.c.
References malloc().
Referenced by resultset_use(), yaz_log_init_globals(), and ZOOM_resultset_create().
void yaz_mutex_destroy | ( | YAZ_MUTEX * | mutexp | ) |
destroy MUTEX
mutexp | pointer to MUTEX handle |
If *mutexp is NULL, then this function does nothing.
Definition at line 141 of file mutex.c.
References free().
Referenced by resultset_destroy(), and yaz_log_deinit_globals().
void yaz_mutex_enter | ( | YAZ_MUTEX | mutex | ) |
enter critical section / AKA lock
mutex | MUTEX handle |
Definition at line 72 of file mutex.c.
References yaz_mutex::log_level, yaz_mutex::name, and yaz_log().
Referenced by resultset_destroy(), resultset_use(), yaz_log_lock(), and ZOOM_resultset_addref().
void yaz_mutex_leave | ( | YAZ_MUTEX | mutex | ) |
leave critical section / AKA unlock
mutex | MUTEX handle |
Definition at line 123 of file mutex.c.
References yaz_mutex::log_level, yaz_mutex::name, and yaz_log().
Referenced by resultset_destroy(), resultset_use(), yaz_log_unlock(), and ZOOM_resultset_addref().
void yaz_mutex_set_name | ( | YAZ_MUTEX | mutex, |
int | log_level, | ||
const char * | name | ||
) |
sets name of MUTEX for debugging purposes
mutex | MUTEX handle |
log_level | YAZ log level |
name | user-given name associated with MUTEX |
If log_level != 0 and name != 0 this function will make yaz_mutex_enter and yaz_mutex_leave print information for each invocation using yaz_log with the level given. In particular when YAZ is compiled with pthreads, yaz_mutex_enter will inform if a lock is not immediately acquired. This function should be called after a MUTEX is created but before it is used for locking.
Definition at line 58 of file mutex.c.
References free(), log_level, yaz_mutex::log_level, malloc(), name, and yaz_mutex::name.