Fork me on GitHub
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Variables
mutex.h File Reference

Semaphors and Mutexes. More...

#include <pthread.h>
Include dependency graph for mutex.h:
This graph shows which files directly or indirectly include this file:

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

Detailed Description

Semaphors and Mutexes.

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Implementation (based on pthread) of a locking mechanism based on mutexes.

Core

Macro Definition Documentation

#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 Documentation

typedef pthread_mutex_t janus_mutex

Janus mutex implementation.

Variable Documentation

int lock_debug