29 #include <sys/timeb.h>
49 InitializeCriticalSection(&(*p)->handle);
50 #elif YAZ_POSIX_THREADS
51 pthread_mutex_init(&(*p)->handle, 0);
77 EnterCriticalSection(&p->handle);
78 #elif YAZ_POSIX_THREADS
83 r = pthread_mutex_trylock(&p->handle);
88 struct timeval tv1, tv2;
89 gettimeofday(&tv1, 0);
92 "yaz_mutex_enter: %p tid=%p name=%s waiting",
93 p, (
void *) pthread_self(), p->
name);
95 r = pthread_mutex_lock(&p->handle);
96 gettimeofday(&tv2, 0);
97 d = 1000000LL * ((
long long) tv2.tv_sec - tv1.tv_sec) +
98 tv2.tv_usec - tv1.tv_usec;
101 p, (
void *) pthread_self(), p->
name, d);
107 p, (
void *) pthread_self(), p->
name);
112 r = pthread_mutex_lock(&p->handle);
116 p, (
void *) pthread_self(), p->
name);
128 LeaveCriticalSection(&p->handle);
129 #elif YAZ_POSIX_THREADS
130 pthread_mutex_unlock(&p->handle);
134 "yaz_mutex_leave: %p tid=%p name=%s unlock",
135 p, (
void *) pthread_self(), p->
name);
146 DeleteCriticalSection(&(*p)->handle);
147 #elif YAZ_POSIX_THREADS
148 pthread_mutex_destroy(&(*p)->handle);
Header for errno utilities.
Header for gettimeofday wrapper.
void yaz_log(int level, const char *fmt,...)
Writes log message.
Declares internal definitions of for Mutex functions.
void yaz_mutex_leave(YAZ_MUTEX p)
leave critical section / AKA unlock
void yaz_mutex_enter(YAZ_MUTEX p)
enter critical section / AKA lock
void yaz_mutex_set_name(YAZ_MUTEX p, int log_level, const char *name)
sets name of MUTEX for debugging purposes
void yaz_mutex_create(YAZ_MUTEX *p)
create MUTEX
void yaz_mutex_destroy(YAZ_MUTEX *p)
destroy MUTEX
Header for Mutex functions.
struct yaz_mutex * YAZ_MUTEX
YAZ MUTEX opaque pointer.
Header for Nibble Memory functions.
Header for memory handling functions.
Header with fundamental macros.