#include "ehs/system/Mutex_PT.h" namespace ehs { Mutex::~Mutex() { if (!initialized) return; pthread_mutex_destroy(&hdl); } Mutex::Mutex() : hdl{} { } Mutex::Mutex(const Mutex& mutex) : BaseMutex(mutex), hdl{} { } Mutex& Mutex::operator=(const Mutex& mutex) { if (this == &mutex) return *this; BaseMutex::operator=(mutex); hdl = {}; return *this; } void Mutex::Initialize() { if (initialized) return; pthread_mutex_t hdl = {}; int code = pthread_mutex_init(&hdl, nullptr); initialized = true; } void Mutex::UnInitialize() { if (!initialized) return; pthread_mutex_destroy(&hdl); initialized = false; } void Mutex::Lock() { if (locked) return; pthread_mutex_lock(&hdl); locked = true; } void Mutex::Unlock() { if (!locked) return; pthread_mutex_unlock(&hdl); locked = false; } }