mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-15 07:06:11 -04:00
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: I8936b527079074d5c3af5531b9245063767cc4a7
27 lines
558 B
C++
27 lines
558 B
C++
#include "platform_v2/impl/shared/posix_mutex.h"
|
|
|
|
namespace location {
|
|
namespace nearby {
|
|
namespace posix {
|
|
|
|
Mutex::Mutex() : attr_(), mutex_() {
|
|
pthread_mutexattr_init(&attr_);
|
|
pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE);
|
|
|
|
pthread_mutex_init(&mutex_, &attr_);
|
|
}
|
|
|
|
Mutex::~Mutex() {
|
|
pthread_mutex_destroy(&mutex_);
|
|
|
|
pthread_mutexattr_destroy(&attr_);
|
|
}
|
|
|
|
void Mutex::Lock() { pthread_mutex_lock(&mutex_); }
|
|
|
|
void Mutex::Unlock() { pthread_mutex_unlock(&mutex_); }
|
|
|
|
} // namespace posix
|
|
} // namespace nearby
|
|
} // namespace location
|