Roll forward to cl/338482889

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: I9850950db8bd84f0904ea1a413151887f52098cf
This commit is contained in:
Alexey Polyudov
2020-10-22 10:47:34 -07:00
parent d68e53cf03
commit 2155b3ddeb
542 changed files with 15219 additions and 42295 deletions
+35
View File
@@ -0,0 +1,35 @@
#ifndef PLATFORM_PUBLIC_CONDITION_VARIABLE_H_
#define PLATFORM_PUBLIC_CONDITION_VARIABLE_H_
#include "platform/api/condition_variable.h"
#include "platform/api/platform.h"
#include "platform/base/exception.h"
#include "platform/public/mutex.h"
namespace location {
namespace nearby {
// The ConditionVariable class is a synchronization primitive that can be used
// to block a thread, or multiple threads at the same time, until another thread
// both modifies a shared variable (the condition), and notifies the
// ConditionVariable.
class ConditionVariable final {
public:
using Platform = api::ImplementationPlatform;
explicit ConditionVariable(Mutex* mutex)
: impl_(Platform::CreateConditionVariable(mutex->impl_.get())) {}
ConditionVariable(ConditionVariable&&) = default;
ConditionVariable& operator=(ConditionVariable&&) = default;
void Notify() { impl_->Notify(); }
Exception Wait() { return impl_->Wait(); }
Exception Wait(absl::Duration timeout) { return impl_->Wait(timeout); }
private:
std::unique_ptr<api::ConditionVariable> impl_;
};
} // namespace nearby
} // namespace location
#endif // PLATFORM_PUBLIC_CONDITION_VARIABLE_H_