Loading...
Searching...
No Matches
mutex.h
Go to the documentation of this file.
1
10#ifndef IMQUIC_MUTEX_H
11#define IMQUIC_MUTEX_H
12
13#include "../imquic/debug.h"
14
15extern gboolean imquic_lock_debug;
16
18typedef GMutex imquic_mutex;
20#define imquic_mutex_init(a) g_mutex_init(a)
22#define IMQUIC_MUTEX_INITIALIZER {0}
24#define imquic_mutex_destroy(a) g_mutex_clear(a)
26#define imquic_mutex_lock_nodebug(a) g_mutex_lock(a)
28#define imquic_mutex_lock_debug(a) { IMQUIC_PRINT("[%s:%s:%d:lock] %p\n", __FILE__, __FUNCTION__, __LINE__, a); g_mutex_lock(a); }
30#define imquic_mutex_lock(a) { if(!imquic_lock_debug) { imquic_mutex_lock_nodebug(a); } else { imquic_mutex_lock_debug(a); } }
32#define imquic_mutex_trylock_nodebug(a) { ret = g_mutex_trylock(a); }
34#define imquic_mutex_trylock_debug(a) { IMQUIC_PRINT("[%s:%s:%d:trylock] %p\n", __FILE__, __FUNCTION__, __LINE__, a); ret = g_mutex_trylock(a); }
36#define imquic_mutex_trylock(a) ({ gboolean ret; if(!imquic_lock_debug) { imquic_mutex_trylock_nodebug(a); } else { imquic_mutex_trylock_debug(a); } ret; })
38#define imquic_mutex_unlock_nodebug(a) g_mutex_unlock(a)
40#define imquic_mutex_unlock_debug(a) { IMQUIC_PRINT("[%s:%s:%d:unlock] %p\n", __FILE__, __FUNCTION__, __LINE__, a); g_mutex_unlock(a); }
42#define imquic_mutex_unlock(a) { if(!imquic_lock_debug) { imquic_mutex_unlock_nodebug(a); } else { imquic_mutex_unlock_debug(a); } }
43
45typedef GCond imquic_condition;
47#define imquic_condition_init(a) g_cond_init(a)
49#define imquic_condition_destroy(a) g_cond_clear(a)
51#define imquic_condition_wait(a, b) g_cond_wait(a, b);
53#define imquic_condition_wait_until(a, b, c) g_cond_wait_until(a, b, c);
55#define imquic_condition_signal(a) g_cond_signal(a);
57#define imquic_condition_broadcast(a) g_cond_broadcast(a);
58
59#endif
Logging and Debugging.
gboolean imquic_lock_debug
Definition imquic.c:29
GCond imquic_condition
imquic condition implementation
Definition mutex.h:45
GMutex imquic_mutex
imquic mutex implementation
Definition mutex.h:18