Semaphors and Mutexes. More...
#include <pthread.h>
Go to the source code of this file.
Macros | |
#define | janus_mutex_init(a) pthread_mutex_init(a,NULL) |
Janus mutex initialization. | |
#define | janus_mutex_destroy(a) pthread_mutex_destroy(a) |
Janus mutex destruction. | |
#define | janus_mutex_lock_nodebug(a) pthread_mutex_lock(a); |
Janus mutex lock without debug. | |
#define | janus_mutex_lock_debug(a) { printf("[%s:%s:%d:] ", __FILE__, __FUNCTION__, __LINE__); printf("LOCK %p\n", a); pthread_mutex_lock(a); }; |
Janus mutex lock with debug (prints the line that locked a mutex) | |
#define | janus_mutex_lock(a) { if(!lock_debug) { janus_mutex_lock_nodebug(a); } else { janus_mutex_lock_debug(a); } }; |
Janus mutex lock wrapper (selective locking debug) | |
#define | janus_mutex_unlock_nodebug(a) pthread_mutex_unlock(a); |
Janus mutex unlock without debug. | |
#define | janus_mutex_unlock_debug(a) { printf("[%s:%s:%d:] ", __FILE__, __FUNCTION__, __LINE__); printf("UNLOCK %p\n", a); pthread_mutex_unlock(a); }; |
Janus mutex unlock with debug (prints the line that unlocked a mutex) | |
#define | janus_mutex_unlock(a) { if(!lock_debug) { janus_mutex_unlock_nodebug(a); } else { janus_mutex_unlock_debug(a); } }; |
Janus mutex unlock wrapper (selective locking debug) |
Typedefs | |
typedef pthread_mutex_t | janus_mutex |
Janus mutex implementation. |
Variables | |
int | lock_debug |
Semaphors and Mutexes.
Implementation (based on pthread) of a locking mechanism based on mutexes.
#define janus_mutex_destroy | ( | a | ) | pthread_mutex_destroy(a) |
Janus mutex destruction.
#define janus_mutex_init | ( | a | ) | pthread_mutex_init(a,NULL) |
Janus mutex initialization.
#define janus_mutex_lock | ( | a | ) | { if(!lock_debug) { janus_mutex_lock_nodebug(a); } else { janus_mutex_lock_debug(a); } }; |
Janus mutex lock wrapper (selective locking debug)
#define janus_mutex_lock_debug | ( | a | ) | { printf("[%s:%s:%d:] ", __FILE__, __FUNCTION__, __LINE__); printf("LOCK %p\n", a); pthread_mutex_lock(a); }; |
Janus mutex lock with debug (prints the line that locked a mutex)
#define janus_mutex_lock_nodebug | ( | a | ) | pthread_mutex_lock(a); |
Janus mutex lock without debug.
#define janus_mutex_unlock | ( | a | ) | { if(!lock_debug) { janus_mutex_unlock_nodebug(a); } else { janus_mutex_unlock_debug(a); } }; |
Janus mutex unlock wrapper (selective locking debug)
#define janus_mutex_unlock_debug | ( | a | ) | { printf("[%s:%s:%d:] ", __FILE__, __FUNCTION__, __LINE__); printf("UNLOCK %p\n", a); pthread_mutex_unlock(a); }; |
Janus mutex unlock with debug (prints the line that unlocked a mutex)
#define janus_mutex_unlock_nodebug | ( | a | ) | pthread_mutex_unlock(a); |
Janus mutex unlock without debug.
typedef pthread_mutex_t janus_mutex |
Janus mutex implementation.
int lock_debug |