Use debug mutex more

This commit is contained in:
Antonio SJ Musumeci 2026-02-20 22:27:55 -06:00 • committed by trapexit
parent 3f70e66ee3
commit a2860c3f1f
26 changed files with 364 additions and 1156 deletions

View file

@ -5,3 +5,48 @@
#else
#include "mutex_ndebug.hpp"
#endif
typedef pthread_mutex_t mutex_t;
// Simple mutex_t wrapper to provide RAII
// Because macros are needed to get location in the code a lock is
// called not making it std::mutex compatible.
class Mutex
{
private:
mutex_t _mutex;
public:
Mutex()
{
mutex_init(_mutex);
}
~Mutex()
{
mutex_destroy(_mutex);
}
operator mutex_t&()
{
return _mutex;
}
};
class LockGuard
{
private:
mutex_t &_mutex;
public:
LockGuard(mutex_t &mutex_)
: _mutex(mutex_)
{
mutex_lock(_mutex);
}
~LockGuard()
{
mutex_unlock(_mutex);
}
};