Skip to content

Commit

Permalink
Add janus_mutex_trylock macro
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelnicolas committed Jun 14, 2021
1 parent 2bc7fc4 commit 145ea4e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ typedef GMutex janus_mutex;
#define janus_mutex_lock_debug(a) { JANUS_PRINT("[%s:%s:%d:lock] %p\n", __FILE__, __FUNCTION__, __LINE__, a); g_mutex_lock(a); }
/*! \brief Janus mutex lock wrapper (selective locking debug) */
#define janus_mutex_lock(a) { if(!lock_debug) { janus_mutex_lock_nodebug(a); } else { janus_mutex_lock_debug(a); } }
/*! \brief Janus mutex try lock without debug */
#define janus_mutex_trylock_nodebug(a) { ret = g_mutex_trylock(a); }
/*! \brief Janus mutex try lock with debug (prints the line that tried to lock a mutex) */
#define janus_mutex_trylock_debug(a) { JANUS_PRINT("[%s:%s:%d:trylock] %p\n", __FILE__, __FUNCTION__, __LINE__, a); ret = g_mutex_trylock(a); }
/*! \brief Janus mutex try lock wrapper (selective locking debug) */
#define janus_mutex_trylock(a) ({ gboolean ret; if(!lock_debug) { janus_mutex_trylock_nodebug(a); } else { janus_mutex_trylock_debug(a); } ret; })
/*! \brief Janus mutex unlock without debug */
#define janus_mutex_unlock_nodebug(a) g_mutex_unlock(a)
/*! \brief Janus mutex unlock with debug (prints the line that unlocked a mutex) */
Expand Down

0 comments on commit 145ea4e

Please sign in to comment.