mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-15 15:16:12 -04:00
Signed-off-by: Alexey Polyudov <apolyudov@google.com> Change-Id: I8936b527079074d5c3af5531b9245063767cc4a7
35 lines
1023 B
C++
35 lines
1023 B
C++
#ifndef PLATFORM_V2_PUBLIC_ATOMIC_BOOLEAN_H_
|
|
#define PLATFORM_V2_PUBLIC_ATOMIC_BOOLEAN_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "platform_v2/api/atomic_boolean.h"
|
|
#include "platform_v2/api/platform.h"
|
|
|
|
namespace location {
|
|
namespace nearby {
|
|
|
|
// A boolean value that may be updated atomically.
|
|
// See documentation in
|
|
// https://source.corp.google.com/piper///depot/google3/platform_v2/api/atomic_boolean.h
|
|
class AtomicBoolean final : public api::AtomicBoolean {
|
|
public:
|
|
using Platform = api::ImplementationPlatform;
|
|
explicit AtomicBoolean(bool value = false)
|
|
: impl_(Platform::CreateAtomicBoolean(value)) {}
|
|
~AtomicBoolean() override = default;
|
|
AtomicBoolean(AtomicBoolean&&) = default;
|
|
AtomicBoolean& operator=(AtomicBoolean&&) = default;
|
|
|
|
bool Get() const override { return impl_->Get(); }
|
|
bool Set(bool value) override { return impl_->Set(value); }
|
|
|
|
private:
|
|
std::unique_ptr<api::AtomicBoolean> impl_;
|
|
};
|
|
|
|
} // namespace nearby
|
|
} // namespace location
|
|
|
|
#endif // PLATFORM_V2_PUBLIC_ATOMIC_BOOLEAN_H_
|