This repository has been archived on 2025-03-22. You can view files and clone it, but cannot push or open issues or pull requests.
travelguide/env/mutex_posix.cpp
2013-08-05 03:10:18 +03:00

33 lines
428 B
C++

#include "mutex.hpp"
#include "posix.hpp"
namespace env
{
Mutex::Mutex()
{
CHECK_POSIX(::pthread_mutex_init(&m_mutex, 0));
}
Mutex::~Mutex()
{
CHECK_POSIX(::pthread_mutex_destroy(&m_mutex));
}
void Mutex::Lock()
{
CHECK_POSIX(::pthread_mutex_lock(&m_mutex));
}
bool Mutex::TryLock()
{
return (0 == ::pthread_mutex_trylock(&m_mutex));
}
void Mutex::Unlock()
{
CHECK_POSIX(::pthread_mutex_unlock(&m_mutex));
}
}