mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: I8936b527079074d5c3af5531b9245063767cc4a7
31 lines
663 B
C++
31 lines
663 B
C++
#include "platform_v2/impl/shared/posix_condition_variable.h"
|
|
|
|
namespace location {
|
|
namespace nearby {
|
|
namespace posix {
|
|
|
|
ConditionVariable::ConditionVariable(Mutex* mutex)
|
|
: mutex_(mutex), attr_(), cond_() {
|
|
pthread_condattr_init(&attr_);
|
|
|
|
pthread_cond_init(&cond_, &attr_);
|
|
}
|
|
|
|
ConditionVariable::~ConditionVariable() {
|
|
pthread_cond_destroy(&cond_);
|
|
|
|
pthread_condattr_destroy(&attr_);
|
|
}
|
|
|
|
void ConditionVariable::Notify() { pthread_cond_broadcast(&cond_); }
|
|
|
|
Exception ConditionVariable::Wait() {
|
|
pthread_cond_wait(&cond_, &(mutex_->mutex_));
|
|
|
|
return {Exception::kSuccess};
|
|
}
|
|
|
|
} // namespace posix
|
|
} // namespace nearby
|
|
} // namespace location
|