mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Fix CreateAtomic* on Windows platform.
PiperOrigin-RevId: 658667651
This commit is contained in:
committed by
Copybara-Service
parent
f2d591e045
commit
1ee946429b
@@ -27,9 +27,8 @@ namespace nearby {
|
||||
// cpp/platform/api/atomic_boolean.h
|
||||
class AtomicBoolean final : public api::AtomicBoolean {
|
||||
public:
|
||||
using Platform = api::ImplementationPlatform;
|
||||
explicit AtomicBoolean(bool value = false)
|
||||
: impl_(Platform::CreateAtomicBoolean(value)) {}
|
||||
: impl_(api::ImplementationPlatform::CreateAtomicBoolean(value)) {}
|
||||
~AtomicBoolean() override = default;
|
||||
AtomicBoolean(AtomicBoolean&&) = default;
|
||||
AtomicBoolean& operator=(AtomicBoolean&&) = default;
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
#include "internal/platform/atomic_boolean.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace windows {
|
||||
// A boolean value that may be updated atomically.
|
||||
class AtomicBoolean : public api::AtomicBoolean {
|
||||
public:
|
||||
explicit AtomicBoolean(bool value = false) : atomic_boolean_(value) {}
|
||||
~AtomicBoolean() override = default;
|
||||
|
||||
// Atomically read and return current value.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define PLATFORM_IMPL_WINDOWS_ATOMIC_REFERENCE_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
#include "internal/platform/implementation/atomic_reference.h"
|
||||
|
||||
@@ -25,6 +26,7 @@ namespace windows {
|
||||
// Type that allows 32-bit atomic reads and writes.
|
||||
class AtomicUint32 : public api::AtomicUint32 {
|
||||
public:
|
||||
explicit AtomicUint32(std::uint32_t value = 0) : atomic_uint32_(value) {}
|
||||
~AtomicUint32() override = default;
|
||||
|
||||
// Atomically reads and returns stored value.
|
||||
|
||||
@@ -38,28 +38,23 @@
|
||||
#include "internal/platform/implementation/shared/count_down_latch.h"
|
||||
#include "internal/platform/implementation/windows/atomic_boolean.h"
|
||||
#include "internal/platform/implementation/windows/atomic_reference.h"
|
||||
#include "internal/platform/implementation/windows/ble.h"
|
||||
#include "internal/platform/implementation/windows/ble_medium.h"
|
||||
#include "internal/platform/implementation/windows/ble_v2.h"
|
||||
#include "internal/platform/implementation/windows/bluetooth_adapter.h"
|
||||
#include "internal/platform/implementation/windows/bluetooth_classic_medium.h"
|
||||
#include "internal/platform/implementation/windows/condition_variable.h"
|
||||
#include "internal/platform/implementation/windows/device_info.h"
|
||||
#include "internal/platform/implementation/windows/executor.h"
|
||||
#include "internal/platform/implementation/windows/file.h"
|
||||
#include "internal/platform/implementation/windows/file_path.h"
|
||||
#include "internal/platform/implementation/windows/future.h"
|
||||
#include "internal/platform/implementation/windows/http_loader.h"
|
||||
#include "internal/platform/implementation/windows/listenable_future.h"
|
||||
#include "internal/platform/implementation/windows/log_message.h"
|
||||
#include "internal/platform/implementation/windows/mutex.h"
|
||||
#include "internal/platform/implementation/windows/preferences_manager.h"
|
||||
#include "internal/platform/implementation/windows/scheduled_executor.h"
|
||||
#include "internal/platform/implementation/windows/server_sync.h"
|
||||
#include "internal/platform/implementation/windows/settable_future.h"
|
||||
#include "internal/platform/implementation/windows/submittable_executor.h"
|
||||
#include "internal/platform/implementation/windows/timer.h"
|
||||
#include "internal/platform/implementation/windows/utils.h"
|
||||
#include "internal/platform/implementation/windows/webrtc.h"
|
||||
#include "internal/platform/implementation/windows/wifi.h"
|
||||
#include "internal/platform/implementation/windows/wifi_hotspot.h"
|
||||
#include "internal/platform/implementation/windows/wifi_lan.h"
|
||||
@@ -165,29 +160,29 @@ OSName ImplementationPlatform::GetCurrentOS() { return OSName::kWindows; }
|
||||
|
||||
std::unique_ptr<AtomicBoolean> ImplementationPlatform::CreateAtomicBoolean(
|
||||
bool initial_value) {
|
||||
return absl::make_unique<windows::AtomicBoolean>();
|
||||
return std::make_unique<windows::AtomicBoolean>(initial_value);
|
||||
}
|
||||
|
||||
std::unique_ptr<AtomicUint32> ImplementationPlatform::CreateAtomicUint32(
|
||||
std::uint32_t value) {
|
||||
return absl::make_unique<windows::AtomicUint32>();
|
||||
return std::make_unique<windows::AtomicUint32>(value);
|
||||
}
|
||||
|
||||
std::unique_ptr<CountDownLatch> ImplementationPlatform::CreateCountDownLatch(
|
||||
std::int32_t count) {
|
||||
return absl::make_unique<shared::CountDownLatch>(count);
|
||||
return std::make_unique<shared::CountDownLatch>(count);
|
||||
}
|
||||
|
||||
#pragma push_macro("CreateMutex")
|
||||
#undef CreateMutex
|
||||
std::unique_ptr<Mutex> ImplementationPlatform::CreateMutex(Mutex::Mode mode) {
|
||||
return absl::make_unique<windows::Mutex>(mode);
|
||||
return std::make_unique<windows::Mutex>(mode);
|
||||
}
|
||||
#pragma pop_macro("CreateMutex")
|
||||
|
||||
std::unique_ptr<ConditionVariable>
|
||||
ImplementationPlatform::CreateConditionVariable(Mutex* mutex) {
|
||||
return absl::make_unique<windows::ConditionVariable>(mutex);
|
||||
return std::make_unique<windows::ConditionVariable>(mutex);
|
||||
}
|
||||
|
||||
ABSL_DEPRECATED("This interface will be deleted in the near future.")
|
||||
@@ -234,39 +229,39 @@ std::unique_ptr<OutputFile> ImplementationPlatform::CreateOutputFile(
|
||||
// TODO(b/184975123): replace with real implementation.
|
||||
std::unique_ptr<LogMessage> ImplementationPlatform::CreateLogMessage(
|
||||
const char* file, int line, LogMessage::Severity severity) {
|
||||
return absl::make_unique<windows::LogMessage>(file, line, severity);
|
||||
return std::make_unique<windows::LogMessage>(file, line, severity);
|
||||
}
|
||||
|
||||
std::unique_ptr<SubmittableExecutor>
|
||||
ImplementationPlatform::CreateSingleThreadExecutor() {
|
||||
return absl::make_unique<windows::SubmittableExecutor>();
|
||||
return std::make_unique<windows::SubmittableExecutor>();
|
||||
}
|
||||
|
||||
std::unique_ptr<SubmittableExecutor>
|
||||
ImplementationPlatform::CreateMultiThreadExecutor(
|
||||
std::int32_t max_concurrency) {
|
||||
return absl::make_unique<windows::SubmittableExecutor>(max_concurrency);
|
||||
return std::make_unique<windows::SubmittableExecutor>(max_concurrency);
|
||||
}
|
||||
|
||||
std::unique_ptr<ScheduledExecutor>
|
||||
ImplementationPlatform::CreateScheduledExecutor() {
|
||||
return absl::make_unique<windows::ScheduledExecutor>();
|
||||
return std::make_unique<windows::ScheduledExecutor>();
|
||||
}
|
||||
|
||||
std::unique_ptr<BluetoothAdapter>
|
||||
ImplementationPlatform::CreateBluetoothAdapter() {
|
||||
return absl::make_unique<windows::BluetoothAdapter>();
|
||||
return std::make_unique<windows::BluetoothAdapter>();
|
||||
}
|
||||
|
||||
std::unique_ptr<BluetoothClassicMedium>
|
||||
ImplementationPlatform::CreateBluetoothClassicMedium(
|
||||
nearby::api::BluetoothAdapter& adapter) {
|
||||
return absl::make_unique<windows::BluetoothClassicMedium>(adapter);
|
||||
return std::make_unique<windows::BluetoothClassicMedium>(adapter);
|
||||
}
|
||||
|
||||
std::unique_ptr<BleMedium> ImplementationPlatform::CreateBleMedium(
|
||||
BluetoothAdapter& adapter) {
|
||||
return absl::make_unique<windows::BleMedium>(adapter);
|
||||
return std::make_unique<windows::BleMedium>(adapter);
|
||||
}
|
||||
|
||||
// TODO(b/184975123): replace with real implementation.
|
||||
@@ -292,7 +287,7 @@ std::unique_ptr<WifiMedium> ImplementationPlatform::CreateWifiMedium() {
|
||||
}
|
||||
|
||||
std::unique_ptr<WifiLanMedium> ImplementationPlatform::CreateWifiLanMedium() {
|
||||
return absl::make_unique<windows::WifiLanMedium>();
|
||||
return std::make_unique<windows::WifiLanMedium>();
|
||||
}
|
||||
|
||||
std::unique_ptr<WifiHotspotMedium>
|
||||
|
||||
Reference in New Issue
Block a user