mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Merge branch 'google3'
Change-Id: Ibebf84b98939ee8e5006beedc34d225e8c2dd413
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
cc_library(
|
||||
name = "default",
|
||||
srcs = [
|
||||
"default_platform.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"default_condition_variable.h",
|
||||
"default_lock.h",
|
||||
"default_platform.h",
|
||||
],
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":condition_variable",
|
||||
":lock",
|
||||
"//platform:types",
|
||||
"//platform/api",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "lock",
|
||||
srcs = ["default_lock.cc"],
|
||||
hdrs = ["default_lock.h"],
|
||||
visibility = [
|
||||
"//platform:__subpackages__",
|
||||
],
|
||||
deps = ["//platform/api:lock"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "condition_variable",
|
||||
srcs = ["default_condition_variable.cc"],
|
||||
hdrs = ["default_condition_variable.h"],
|
||||
visibility = [
|
||||
"//platform:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":lock",
|
||||
"//platform:types",
|
||||
"//platform/api:condition_variable",
|
||||
],
|
||||
)
|
||||
@@ -1,51 +0,0 @@
|
||||
add_library(platform_impl_default STATIC)
|
||||
|
||||
target_sources(platform_impl_default
|
||||
PRIVATE
|
||||
default_platform.cc
|
||||
PUBLIC
|
||||
default_platform.h
|
||||
)
|
||||
|
||||
target_include_directories(platform_impl_default
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(platform_impl_default
|
||||
PUBLIC
|
||||
platform_api
|
||||
platform_impl_default_cond_var
|
||||
platform_impl_default_lock
|
||||
platform_types
|
||||
)
|
||||
|
||||
add_library(platform_impl_default_lock STATIC)
|
||||
|
||||
target_sources(platform_impl_default_lock
|
||||
PRIVATE
|
||||
default_lock.cc
|
||||
PUBLIC
|
||||
default_lock.h
|
||||
)
|
||||
|
||||
target_link_libraries(platform_impl_default_lock
|
||||
PUBLIC
|
||||
platform_api
|
||||
)
|
||||
|
||||
add_library(platform_impl_default_cond_var STATIC)
|
||||
|
||||
target_sources(platform_impl_default_cond_var
|
||||
PRIVATE
|
||||
default_condition_variable.cc
|
||||
PUBLIC
|
||||
default_condition_variable.h
|
||||
)
|
||||
|
||||
target_link_libraries(platform_impl_default_cond_var
|
||||
PUBLIC
|
||||
platform_api
|
||||
platform_impl_default_lock
|
||||
platform_types
|
||||
)
|
||||
@@ -1,28 +0,0 @@
|
||||
#include "platform/impl/default/default_condition_variable.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
DefaultConditionVariable::DefaultConditionVariable(Ptr<DefaultLock> lock)
|
||||
: lock_(lock), attr_(), cond_() {
|
||||
pthread_condattr_init(&attr_);
|
||||
|
||||
pthread_cond_init(&cond_, &attr_);
|
||||
}
|
||||
|
||||
DefaultConditionVariable::~DefaultConditionVariable() {
|
||||
pthread_cond_destroy(&cond_);
|
||||
|
||||
pthread_condattr_destroy(&attr_);
|
||||
}
|
||||
|
||||
void DefaultConditionVariable::notify() { pthread_cond_broadcast(&cond_); }
|
||||
|
||||
Exception::Value DefaultConditionVariable::wait() {
|
||||
pthread_cond_wait(&cond_, &(lock_->mutex_));
|
||||
|
||||
return Exception::NONE;
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef PLATFORM_IMPL_DEFAULT_DEFAULT_CONDITION_VARIABLE_H_
|
||||
#define PLATFORM_IMPL_DEFAULT_DEFAULT_CONDITION_VARIABLE_H_
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "platform/api/condition_variable.h"
|
||||
#include "platform/impl/default/default_lock.h"
|
||||
#include "platform/ptr.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
class DefaultConditionVariable : public ConditionVariable {
|
||||
public:
|
||||
explicit DefaultConditionVariable(Ptr<DefaultLock> lock);
|
||||
~DefaultConditionVariable() override;
|
||||
|
||||
void notify() override;
|
||||
Exception::Value wait() override;
|
||||
|
||||
private:
|
||||
Ptr<DefaultLock> lock_;
|
||||
pthread_condattr_t attr_;
|
||||
pthread_cond_t cond_;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_DEFAULT_DEFAULT_CONDITION_VARIABLE_H_
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "platform/impl/default/default_platform.h"
|
||||
|
||||
#include "platform/impl/default/default_condition_variable.h"
|
||||
#include "platform/impl/default/default_lock.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
Ptr<Lock> DefaultPlatform::createLock() { return MakePtr(new DefaultLock()); }
|
||||
|
||||
Ptr<ConditionVariable> DefaultPlatform::createConditionVariable(
|
||||
Ptr<Lock> lock) {
|
||||
return MakePtr(new DefaultConditionVariable(DowncastPtr<DefaultLock>(lock)));
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef PLATFORM_IMPL_DEFAULT_DEFAULT_PLATFORM_H_
|
||||
#define PLATFORM_IMPL_DEFAULT_DEFAULT_PLATFORM_H_
|
||||
|
||||
#include "platform/api/condition_variable.h"
|
||||
#include "platform/api/lock.h"
|
||||
#include "platform/ptr.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
// Provides obvious portable implementations of a subset of the hooks specified
|
||||
// within //platform/api/.
|
||||
//
|
||||
// It's highly recommended that custom Platform implementations delegate to
|
||||
// these methods unless there's a very good reason not to.
|
||||
class DefaultPlatform {
|
||||
public:
|
||||
static Ptr<Lock> createLock();
|
||||
|
||||
static Ptr<ConditionVariable> createConditionVariable(Ptr<Lock> lock);
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_DEFAULT_DEFAULT_PLATFORM_H_
|
||||
@@ -0,0 +1,26 @@
|
||||
cc_library(
|
||||
name = "g3",
|
||||
srcs = [
|
||||
"atomic_reference_impl.h",
|
||||
"platform.cc",
|
||||
"settable_future_impl.h",
|
||||
"system_clock_impl.h",
|
||||
],
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
"//platform:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//platform:types",
|
||||
"//platform/api",
|
||||
"//platform/impl/shared:atomic_boolean",
|
||||
"//platform/impl/shared:posix_condition_variable",
|
||||
"//platform/impl/shared:posix_lock",
|
||||
"//platform/port:string",
|
||||
"//absl/base:core_headers",
|
||||
"//absl/synchronization",
|
||||
"//absl/time",
|
||||
"//absl/types:any",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
add_library(platform_impl_g3 STATIC)
|
||||
|
||||
target_sources(platform_impl_g3
|
||||
PRIVATE
|
||||
"atomic_reference_impl.h"
|
||||
"platform.cc"
|
||||
"settable_future_impl.h"
|
||||
"system_clock_impl.h"
|
||||
)
|
||||
|
||||
target_include_directories(platform_impl_g3
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(platform_impl_g3
|
||||
PUBLIC
|
||||
"platform_types"
|
||||
"platform_api"
|
||||
"platform_impl_shared_atomic_boolean"
|
||||
"platform_impl_shared_posix_condition_variable"
|
||||
"platform_impl_shared_posix_lock"
|
||||
"platform_port_string"
|
||||
"absl::base"
|
||||
"absl::synchronization"
|
||||
"absl::time"
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef PLATFORM_IMPL_G3_ATOMIC_REFERENCE_IMPL_H_
|
||||
#define PLATFORM_IMPL_G3_ATOMIC_REFERENCE_IMPL_H_
|
||||
|
||||
#include "platform/api/atomic_reference.h"
|
||||
#include "platform/ptr.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "absl/types/any.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace platform {
|
||||
|
||||
// Provide implementation for absl::any.
|
||||
class AtomicReferenceImpl : public AtomicReference<absl::any> {
|
||||
public:
|
||||
explicit AtomicReferenceImpl(absl::any initial_value)
|
||||
: value_(std::move(initial_value)) {}
|
||||
~AtomicReferenceImpl() override = default;
|
||||
|
||||
absl::any get() override {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
return value_;
|
||||
}
|
||||
void set(absl::any value) override {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
value_ = std::move(value);
|
||||
}
|
||||
|
||||
private:
|
||||
absl::Mutex mutex_;
|
||||
absl::any value_;
|
||||
};
|
||||
|
||||
} // namespace platform
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_G3_ATOMIC_REFERENCE_IMPL_H_
|
||||
@@ -0,0 +1,140 @@
|
||||
#include "platform/api/platform.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
#include "platform/api/atomic_boolean.h"
|
||||
#include "platform/api/atomic_reference.h"
|
||||
#include "platform/api/ble.h"
|
||||
#include "platform/api/ble_v2.h"
|
||||
#include "platform/api/bluetooth_adapter.h"
|
||||
#include "platform/api/bluetooth_classic.h"
|
||||
#include "platform/api/condition_variable.h"
|
||||
#include "platform/api/count_down_latch.h"
|
||||
#include "platform/api/hash_utils.h"
|
||||
#include "platform/api/lock.h"
|
||||
#include "platform/api/scheduled_executor.h"
|
||||
#include "platform/api/server_sync.h"
|
||||
#include "platform/api/settable_future.h"
|
||||
#include "platform/api/submittable_executor.h"
|
||||
#include "platform/api/system_clock.h"
|
||||
#include "platform/api/thread_utils.h"
|
||||
#include "platform/api/webrtc.h"
|
||||
#include "platform/api/wifi.h"
|
||||
#include "platform/impl/g3/atomic_reference_impl.h"
|
||||
#include "platform/impl/g3/settable_future_impl.h"
|
||||
#include "platform/impl/g3/system_clock_impl.h"
|
||||
#include "platform/impl/shared/atomic_boolean_impl.h"
|
||||
#include "platform/impl/shared/posix_condition_variable.h"
|
||||
#include "platform/impl/shared/posix_lock.h"
|
||||
#include "platform/port/string.h"
|
||||
#include "platform/ptr.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "absl/time/time.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace platform {
|
||||
|
||||
Ptr<SubmittableExecutor> ImplementationPlatform::createSingleThreadExecutor() {
|
||||
return Ptr<SubmittableExecutor>(/*new SingleThreadExecutorImpl()*/);
|
||||
}
|
||||
|
||||
Ptr<SubmittableExecutor> ImplementationPlatform::createMultiThreadExecutor(
|
||||
int max_concurrency) {
|
||||
return Ptr<SubmittableExecutor>(/*new MultiThreadExecutorImpl()*/);
|
||||
}
|
||||
|
||||
Ptr<ScheduledExecutor> ImplementationPlatform::createScheduledExecutor() {
|
||||
return Ptr<ScheduledExecutor>(/*new ScheduledExecutorImpl()*/);
|
||||
}
|
||||
|
||||
Ptr<AtomicReference<absl::any>>
|
||||
ImplementationPlatform::createAtomicReferenceAny(absl::any initial_value) {
|
||||
return Ptr<AtomicReference<absl::any>>(
|
||||
new AtomicReferenceImpl(initial_value));
|
||||
}
|
||||
|
||||
Ptr<SettableFuture<absl::any>>
|
||||
ImplementationPlatform::createSettableFutureAny() {
|
||||
return Ptr<SettableFuture<std::any>>(new SettableFutureImpl{});
|
||||
}
|
||||
|
||||
Ptr<BluetoothAdapter> ImplementationPlatform::createBluetoothAdapter() {
|
||||
return Ptr<BluetoothAdapter>{};
|
||||
}
|
||||
|
||||
Ptr<WifiMedium> ImplementationPlatform::createWifiMedium() {
|
||||
return Ptr<WifiMedium>();
|
||||
}
|
||||
|
||||
Ptr<CountDownLatch> ImplementationPlatform::createCountDownLatch(
|
||||
std::int32_t count) {
|
||||
return Ptr<CountDownLatch>(/*new CountDownLatchImpl(count)*/);
|
||||
}
|
||||
|
||||
Ptr<ThreadUtils> ImplementationPlatform::createThreadUtils() {
|
||||
return Ptr<ThreadUtils>(/*new ThreadUtilsImpl()*/);
|
||||
}
|
||||
|
||||
Ptr<SystemClock> ImplementationPlatform::createSystemClock() {
|
||||
return Ptr<SystemClock>(new SystemClockImpl());
|
||||
}
|
||||
|
||||
Ptr<AtomicBoolean> ImplementationPlatform::createAtomicBoolean(
|
||||
bool initial_value) {
|
||||
return Ptr<AtomicBoolean>(new AtomicBooleanImpl(initial_value));
|
||||
}
|
||||
|
||||
Ptr<BluetoothClassicMedium>
|
||||
ImplementationPlatform::createBluetoothClassicMedium() {
|
||||
return Ptr<BluetoothClassicMedium>();
|
||||
}
|
||||
|
||||
Ptr<BLEMedium> ImplementationPlatform::createBLEMedium() {
|
||||
return Ptr<BLEMedium>();
|
||||
}
|
||||
|
||||
Ptr<BLEMediumV2> ImplementationPlatform::createBLEMediumV2() {
|
||||
return Ptr<BLEMediumV2>();
|
||||
}
|
||||
|
||||
Ptr<ServerSyncMedium> ImplementationPlatform::createServerSyncMedium() {
|
||||
return Ptr<ServerSyncMedium>(/*new ServerSyncMediumImpl()*/);
|
||||
}
|
||||
|
||||
Ptr<WifiLanMedium> ImplementationPlatform::createWifiLanMedium() {
|
||||
return Ptr<WifiLanMedium>();
|
||||
}
|
||||
|
||||
//Ptr<WebRtcSignalingMessenger>
|
||||
//ImplementationPlatform::createWebRtcSignalingMessenger(
|
||||
// const std::string& self_id) {
|
||||
// return Ptr<WebRtcSignalingMessenger>(/*new FCMSignalingMessenger()*/);
|
||||
//}
|
||||
|
||||
Ptr<Lock> ImplementationPlatform::createLock() {
|
||||
return Ptr<Lock>(new PosixLock());
|
||||
}
|
||||
|
||||
Ptr<ConditionVariable> ImplementationPlatform::createConditionVariable(
|
||||
Ptr<Lock> lock) {
|
||||
return Ptr<ConditionVariable>(new PosixConditionVariable(lock));
|
||||
}
|
||||
|
||||
Ptr<HashUtils> ImplementationPlatform::createHashUtils() {
|
||||
return Ptr<HashUtils>(/*new HashUtilsImpl()*/);
|
||||
}
|
||||
|
||||
std::string ImplementationPlatform::getDeviceId() {
|
||||
// TODO(alexchau): Get deviceId from base
|
||||
return "google3";
|
||||
}
|
||||
|
||||
std::string ImplementationPlatform::getPayloadPath(int64_t payload_id) {
|
||||
return "/tmp/" + std::to_string(payload_id);
|
||||
}
|
||||
|
||||
} // namespace platform
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
@@ -0,0 +1,94 @@
|
||||
#ifndef PLATFORM_IMPL_G3_SETTABLE_FUTURE_IMPL_H_
|
||||
#define PLATFORM_IMPL_G3_SETTABLE_FUTURE_IMPL_H_
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "platform/api/platform.h"
|
||||
#include "platform/api/settable_future.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/types/any.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace platform {
|
||||
|
||||
class SettableFutureImpl : public SettableFuture<absl::any> {
|
||||
public:
|
||||
explicit SettableFutureImpl() = default;
|
||||
~SettableFutureImpl() override = default;
|
||||
|
||||
bool set(absl::any value) override {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (!done_) {
|
||||
value_ = std::move(value);
|
||||
done_ = true;
|
||||
exception_ = {Exception::kSuccess};
|
||||
completed_.SignalAll();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool setException(Exception exception) override {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
return SetExceptionLocked(exception);
|
||||
}
|
||||
|
||||
void addListener(Ptr<Runnable> runnable, Executor* executor) override {}
|
||||
|
||||
ExceptionOr<std::any> get() override {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
while (!done_) {
|
||||
completed_.Wait(&mutex_);
|
||||
}
|
||||
return exception_.value != Exception::kSuccess
|
||||
? ExceptionOr<std::any>{exception_.value}
|
||||
: ExceptionOr<std::any>{value_};
|
||||
}
|
||||
|
||||
ExceptionOr<std::any> get(std::int64_t timeout_ms) override {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
absl::Duration timeout = absl::Milliseconds(timeout_ms);
|
||||
while (!done_) {
|
||||
absl::Time start_time = absl::Now();
|
||||
if (completed_.WaitWithTimeout(&mutex_, timeout)) {
|
||||
SetExceptionLocked({Exception::kTimeout});
|
||||
break;
|
||||
}
|
||||
absl::Duration spent = absl::Now() - start_time;
|
||||
if (spent < timeout) {
|
||||
timeout -= spent;
|
||||
} else if (!done_) {
|
||||
SetExceptionLocked({Exception::kTimeout});
|
||||
break;
|
||||
}
|
||||
}
|
||||
return exception_.value != Exception::kSuccess
|
||||
? ExceptionOr<std::any>{exception_.value}
|
||||
: ExceptionOr<std::any>{value_};
|
||||
}
|
||||
|
||||
private:
|
||||
bool SetExceptionLocked(Exception exception) {
|
||||
if (!done_) {
|
||||
exception_ = exception.value != Exception::kSuccess
|
||||
? exception
|
||||
: Exception{Exception::kFailed};
|
||||
done_ = true;
|
||||
completed_.SignalAll();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
absl::Mutex mutex_;
|
||||
absl::CondVar completed_;
|
||||
bool done_{false};
|
||||
absl::any value_;
|
||||
Exception exception_{Exception::kFailed};
|
||||
};
|
||||
|
||||
} // namespace platform
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_G3_SETTABLE_FUTURE_IMPL_H_
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef PLATFORM_IMPL_G3_SYSTEM_CLOCK_IMPL_H_
|
||||
#define PLATFORM_IMPL_G3_SYSTEM_CLOCK_IMPL_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "platform/api/system_clock.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
class SystemClockImpl : public SystemClock {
|
||||
public:
|
||||
std::int64_t elapsedRealtime() override {
|
||||
return absl::ToUnixMillis(absl::Now());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_G3_SYSTEM_CLOCK_IMPL_H_
|
||||
@@ -1,10 +1,10 @@
|
||||
cc_library(
|
||||
name = "sample",
|
||||
name = "sample_platform",
|
||||
srcs = [
|
||||
"sample_wifi_medium.cc",
|
||||
"sample_wifi_medium.h",
|
||||
"atomic_reference_impl.h",
|
||||
"sample_platform.cc",
|
||||
"settable_future_impl.h",
|
||||
],
|
||||
hdrs = ["sample_platform.h"],
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
@@ -14,7 +14,9 @@ cc_library(
|
||||
"//platform:types",
|
||||
"//platform:utils",
|
||||
"//platform/api",
|
||||
"//platform/impl/shared/sample:sample_wifi_medium",
|
||||
"//platform/port:string",
|
||||
"//absl/time",
|
||||
"//absl/types:any",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef PLATFORM_IMPL_SAMPLE_ATOMIC_REFERENCE_IMPL_H_
|
||||
#define PLATFORM_IMPL_SAMPLE_ATOMIC_REFERENCE_IMPL_H_
|
||||
|
||||
#include "platform/api/atomic_reference_def.h"
|
||||
#include "absl/types/any.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace platform {
|
||||
|
||||
// Provide implementation for absl::any.
|
||||
class AtomicReferenceImpl : public AtomicReference<absl::any> {
|
||||
public:
|
||||
explicit AtomicReferenceImpl(absl::any initial_value) {}
|
||||
~AtomicReferenceImpl() override = default;
|
||||
|
||||
absl::any get() override { return {}; }
|
||||
void set(absl::any value) override {}
|
||||
};
|
||||
|
||||
} // namespace platform
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_SAMPLE_ATOMIC_REFERENCE_IMPL_H_
|
||||
@@ -0,0 +1,125 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "platform/api/atomic_boolean.h"
|
||||
#include "platform/api/atomic_reference_def.h"
|
||||
#include "platform/api/ble.h"
|
||||
#include "platform/api/ble_v2.h"
|
||||
#include "platform/api/bluetooth_adapter.h"
|
||||
#include "platform/api/bluetooth_classic.h"
|
||||
#include "platform/api/condition_variable.h"
|
||||
#include "platform/api/count_down_latch.h"
|
||||
#include "platform/api/hash_utils.h"
|
||||
#include "platform/api/lock.h"
|
||||
#include "platform/api/platform.h"
|
||||
#include "platform/api/server_sync.h"
|
||||
#include "platform/api/settable_future_def.h"
|
||||
#include "platform/api/submittable_executor_def.h"
|
||||
#include "platform/api/system_clock.h"
|
||||
#include "platform/api/thread_utils.h"
|
||||
#include "platform/api/wifi.h"
|
||||
#include "platform/cancelable.h"
|
||||
#include "platform/impl/sample/atomic_reference_impl.h"
|
||||
#include "platform/impl/sample/settable_future_impl.h"
|
||||
#include "platform/impl/shared/sample/sample_wifi_medium.h"
|
||||
#include "platform/port/string.h"
|
||||
#include "platform/ptr.h"
|
||||
#include "platform/runnable.h"
|
||||
#include "absl/types/any.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace platform {
|
||||
|
||||
Ptr<ScheduledExecutor> ImplementationPlatform::createScheduledExecutor() {
|
||||
return Ptr<ScheduledExecutor>{};
|
||||
}
|
||||
|
||||
Ptr<SubmittableExecutor> ImplementationPlatform::createSingleThreadExecutor() {
|
||||
return Ptr<SubmittableExecutor>{};
|
||||
}
|
||||
|
||||
Ptr<SubmittableExecutor> ImplementationPlatform::createMultiThreadExecutor(
|
||||
int max_concurrency) {
|
||||
return Ptr<SubmittableExecutor>{};
|
||||
}
|
||||
|
||||
Ptr<AtomicReference<absl::any>>
|
||||
ImplementationPlatform::createAtomicReferenceAny(absl::any initial_value) {
|
||||
return Ptr<AtomicReference<absl::any>>(
|
||||
new AtomicReferenceImpl(initial_value));
|
||||
}
|
||||
|
||||
Ptr<SettableFuture<absl::any>>
|
||||
ImplementationPlatform::createSettableFutureAny() {
|
||||
return Ptr<SettableFuture<absl::any>>(new SettableFutureImpl{});
|
||||
}
|
||||
|
||||
Ptr<BluetoothAdapter> ImplementationPlatform::createBluetoothAdapter() {
|
||||
return Ptr<BluetoothAdapter>{};
|
||||
}
|
||||
|
||||
Ptr<WifiMedium> ImplementationPlatform::createWifiMedium() {
|
||||
return Ptr<WifiMedium>();
|
||||
}
|
||||
|
||||
Ptr<CountDownLatch> ImplementationPlatform::createCountDownLatch(
|
||||
std::int32_t count) {
|
||||
return Ptr<CountDownLatch>{};
|
||||
}
|
||||
|
||||
Ptr<ThreadUtils> ImplementationPlatform::createThreadUtils() {
|
||||
return Ptr<ThreadUtils>{};
|
||||
}
|
||||
|
||||
Ptr<SystemClock> ImplementationPlatform::createSystemClock() {
|
||||
return Ptr<SystemClock>{};
|
||||
}
|
||||
|
||||
Ptr<AtomicBoolean> ImplementationPlatform::createAtomicBoolean(
|
||||
bool initial_value) {
|
||||
return Ptr<AtomicBoolean>{};
|
||||
}
|
||||
|
||||
Ptr<BluetoothClassicMedium>
|
||||
ImplementationPlatform::createBluetoothClassicMedium() {
|
||||
return Ptr<BluetoothClassicMedium>();
|
||||
}
|
||||
|
||||
Ptr<BLEMedium> ImplementationPlatform::createBLEMedium() {
|
||||
return Ptr<BLEMedium>();
|
||||
}
|
||||
|
||||
Ptr<BLEMediumV2> ImplementationPlatform::createBLEMediumV2() {
|
||||
return Ptr<BLEMediumV2>();
|
||||
}
|
||||
|
||||
Ptr<ServerSyncMedium> ImplementationPlatform::createServerSyncMedium() {
|
||||
return Ptr<ServerSyncMedium>{};
|
||||
}
|
||||
|
||||
Ptr<WebRtcSignalingMessenger>
|
||||
ImplementationPlatform::createWebRtcSignalingMessenger(
|
||||
const std::string& self_id) {
|
||||
return Ptr<WebRtcSignalingMessenger>{};
|
||||
}
|
||||
|
||||
Ptr<Lock> ImplementationPlatform::createLock() { return Ptr<Lock>{}; }
|
||||
|
||||
Ptr<ConditionVariable> ImplementationPlatform::createConditionVariable(
|
||||
Ptr<Lock> lock) {
|
||||
return Ptr<ConditionVariable>{};
|
||||
}
|
||||
|
||||
Ptr<HashUtils> ImplementationPlatform::createHashUtils() {
|
||||
return Ptr<HashUtils>{};
|
||||
}
|
||||
|
||||
std::string ImplementationPlatform::getDeviceId() { return "sample"; }
|
||||
|
||||
std::string ImplementationPlatform::getPayloadPath(int64_t payload_id) {
|
||||
return "/tmp/sample-" + std::to_string(payload_id);
|
||||
}
|
||||
|
||||
} // namespace platform
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
@@ -1,141 +0,0 @@
|
||||
#ifndef PLATFORM_IMPL_SAMPLE_SAMPLE_PLATFORM_H_
|
||||
#define PLATFORM_IMPL_SAMPLE_SAMPLE_PLATFORM_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "platform/api/atomic_boolean.h"
|
||||
#include "platform/api/atomic_reference.h"
|
||||
#include "platform/api/ble.h"
|
||||
#include "platform/api/ble_v2.h"
|
||||
#include "platform/api/bluetooth_adapter.h"
|
||||
#include "platform/api/bluetooth_classic.h"
|
||||
#include "platform/api/condition_variable.h"
|
||||
#include "platform/api/count_down_latch.h"
|
||||
#include "platform/api/hash_utils.h"
|
||||
#include "platform/api/lock.h"
|
||||
#include "platform/api/multi_thread_executor.h"
|
||||
#include "platform/api/settable_future.h"
|
||||
#include "platform/api/single_thread_executor.h"
|
||||
#include "platform/api/system_clock.h"
|
||||
#include "platform/api/thread_utils.h"
|
||||
#include "platform/api/wifi.h"
|
||||
#include "platform/cancelable.h"
|
||||
#include "platform/impl/sample/sample_wifi_medium.h"
|
||||
#include "platform/port/string.h"
|
||||
#include "platform/ptr.h"
|
||||
#include "platform/runnable.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace sample {
|
||||
|
||||
// The SamplePlatform class below shows an example of the factory functions
|
||||
// and typedefs.
|
||||
class SamplePlatform {
|
||||
public:
|
||||
class SampleSubmittableExecutor
|
||||
: public SubmittableExecutor<SampleSubmittableExecutor> {
|
||||
public:
|
||||
template <typename T>
|
||||
Ptr<Future<T> > submit(Ptr<Callable<T> > callable) {
|
||||
return Ptr<Future<T> >();
|
||||
}
|
||||
};
|
||||
|
||||
class SampleSingleThreadExecutor
|
||||
: public SingleThreadExecutor<SampleSubmittableExecutor> {
|
||||
public:
|
||||
void execute(Ptr<Runnable> runnable) override {}
|
||||
void shutdown() override {}
|
||||
};
|
||||
|
||||
class SampleMultiThreadExecutor
|
||||
: public MultiThreadExecutor<SampleSubmittableExecutor> {
|
||||
public:
|
||||
void execute(Ptr<Runnable> runnable) override {}
|
||||
void shutdown() override {}
|
||||
};
|
||||
|
||||
class SampleScheduledExecutor {
|
||||
public:
|
||||
Ptr<Cancelable> schedule(Ptr<Runnable> runnable,
|
||||
std::int64_t delay_millis) {
|
||||
return Ptr<Cancelable>();
|
||||
}
|
||||
void shutdown() {}
|
||||
};
|
||||
|
||||
typedef SampleSingleThreadExecutor SingleThreadExecutorType;
|
||||
static Ptr<SingleThreadExecutorType> createSingleThreadExecutor() {
|
||||
return MakePtr(new SingleThreadExecutorType());
|
||||
}
|
||||
|
||||
typedef SampleMultiThreadExecutor MultiThreadExecutorType;
|
||||
static Ptr<MultiThreadExecutorType> createMultiThreadExecutor(
|
||||
std::int32_t max_concurrency) {
|
||||
return MakePtr(new MultiThreadExecutorType());
|
||||
}
|
||||
|
||||
typedef SampleScheduledExecutor ScheduledExecutorType;
|
||||
static Ptr<ScheduledExecutorType> createScheduledExecutor() {
|
||||
return MakePtr(new ScheduledExecutorType());
|
||||
}
|
||||
|
||||
static Ptr<BluetoothAdapter> createBluetoothAdapter() {
|
||||
return Ptr<BluetoothAdapter>();
|
||||
}
|
||||
|
||||
static Ptr<WifiMedium> createWifiMedium() {
|
||||
return MakePtr(new SampleWifiMedium());
|
||||
}
|
||||
|
||||
static Ptr<CountDownLatch> createCountDownLatch(std::int32_t count) {
|
||||
return Ptr<CountDownLatch>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static Ptr<SettableFuture<T> > createSettableFuture() {
|
||||
return Ptr<SettableFuture<T> >();
|
||||
}
|
||||
|
||||
static Ptr<ThreadUtils> createThreadUtils() { return Ptr<ThreadUtils>(); }
|
||||
|
||||
static Ptr<SystemClock> createSystemClock() { return Ptr<SystemClock>(); }
|
||||
|
||||
static Ptr<AtomicBoolean> createAtomicBoolean(bool initial_value) {
|
||||
return Ptr<AtomicBoolean>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static Ptr<AtomicReference<T> > createAtomicReference(T initial_value) {
|
||||
return Ptr<AtomicReference<T> >();
|
||||
}
|
||||
|
||||
static Ptr<BluetoothClassicMedium> createBluetoothClassicMedium() {
|
||||
return Ptr<BluetoothClassicMedium>();
|
||||
}
|
||||
|
||||
static Ptr<BLEMedium> createBLEMedium() { return Ptr<BLEMedium>(); }
|
||||
|
||||
static Ptr<BLEMediumV2> createBLEMediumV2() { return Ptr<BLEMediumV2>(); }
|
||||
|
||||
static Ptr<Lock> createLock() { return Ptr<Lock>(); }
|
||||
|
||||
static Ptr<ConditionVariable> createConditionVariable(Ptr<Lock> lock) {
|
||||
return Ptr<ConditionVariable>();
|
||||
}
|
||||
|
||||
static Ptr<HashUtils> createHashUtils() { return Ptr<HashUtils>(); }
|
||||
|
||||
static std::string getDeviceId() { return ""; }
|
||||
|
||||
static std::string getPayloadPath(int64_t payload_id) {
|
||||
return "/tmp/" + std::to_string(payload_id);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace sample
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_SAMPLE_SAMPLE_PLATFORM_H_
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef PLATFORM_IMPL_SAMPLE_SETTABLE_FUTURE_IMPL_H_
|
||||
#define PLATFORM_IMPL_SAMPLE_SETTABLE_FUTURE_IMPL_H_
|
||||
|
||||
#include "platform/api/settable_future_def.h"
|
||||
#include "absl/types/any.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace platform {
|
||||
|
||||
class SettableFutureImpl : public SettableFuture<absl::any> {
|
||||
public:
|
||||
explicit SettableFutureImpl() = default;
|
||||
~SettableFutureImpl() override = default;
|
||||
|
||||
bool set(absl::any value) override { return true; }
|
||||
|
||||
bool setException(Exception exception) override { return true; }
|
||||
|
||||
void addListener(Ptr<Runnable> runnable, Executor* executor) override {}
|
||||
|
||||
ExceptionOr<std::any> get() override {
|
||||
return ExceptionOr<std::any>{Exception{Exception::kFailed}};
|
||||
}
|
||||
|
||||
ExceptionOr<std::any> get(std::int64_t timeout_ms) override {
|
||||
return ExceptionOr<std::any>{Exception{Exception::kFailed}};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace platform
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_SAMPLE_SETTABLE_FUTURE_IMPL_H_
|
||||
@@ -0,0 +1,45 @@
|
||||
cc_library(
|
||||
name = "posix_lock",
|
||||
srcs = [
|
||||
"posix_lock.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"posix_lock.h",
|
||||
],
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//platform/impl:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//platform/api",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "posix_condition_variable",
|
||||
srcs = [
|
||||
"posix_condition_variable.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"posix_condition_variable.h",
|
||||
],
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//platform/impl:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":posix_lock",
|
||||
"//platform:types",
|
||||
"//platform/api:condition_variable",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "atomic_boolean",
|
||||
hdrs = ["atomic_boolean_impl.h"],
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//platform/impl:__subpackages__",
|
||||
],
|
||||
deps = ["//platform/api"],
|
||||
)
|
||||
@@ -0,0 +1,67 @@
|
||||
add_library(platform_impl_shared_posix_lock STATIC)
|
||||
|
||||
target_sources(platform_impl_shared_posix_lock
|
||||
PRIVATE
|
||||
"posix_lock.cc"
|
||||
PUBLIC
|
||||
"posix_lock.h"
|
||||
)
|
||||
|
||||
target_include_directories(platform_impl_shared_posix_lock
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
|
||||
target_link_libraries(platform_impl_shared_posix_lock
|
||||
PUBLIC
|
||||
platform_api
|
||||
platform_types
|
||||
)
|
||||
|
||||
add_library(platform_impl_shared_posix_condition_variable STATIC)
|
||||
|
||||
target_sources(platform_impl_shared_posix_condition_variable
|
||||
PRIVATE
|
||||
"posix_condition_variable.cc"
|
||||
PUBLIC
|
||||
"posix_condition_variable.h"
|
||||
)
|
||||
|
||||
target_include_directories(platform_impl_shared_posix_condition_variable
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(platform_impl_shared_posix_condition_variable
|
||||
PUBLIC
|
||||
platform_api
|
||||
platform_impl_shared_posix_lock
|
||||
platform_types
|
||||
absl::raw_logging_internal
|
||||
)
|
||||
|
||||
add_library(platform_impl_shared_atomic_boolean STATIC)
|
||||
|
||||
target_sources(platform_impl_shared_atomic_boolean
|
||||
PUBLIC
|
||||
"atomic_boolean_impl.h"
|
||||
)
|
||||
|
||||
target_include_directories(platform_impl_shared_atomic_boolean
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(platform_impl_shared_atomic_boolean
|
||||
PUBLIC
|
||||
platform_api
|
||||
platform_types
|
||||
)
|
||||
|
||||
set_target_properties(platform_impl_shared_atomic_boolean
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
)
|
||||
|
||||
add_subdirectory(sample)
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef PLATFORM_IMPL_SHARED_ATOMIC_BOOLEAN_IMPL_H_
|
||||
#define PLATFORM_IMPL_SHARED_ATOMIC_BOOLEAN_IMPL_H_
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "platform/api/atomic_boolean.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
class AtomicBooleanImpl : public AtomicBoolean {
|
||||
public:
|
||||
explicit AtomicBooleanImpl(bool initial_value) : value_(initial_value) {}
|
||||
~AtomicBooleanImpl() override = default;
|
||||
|
||||
// AtomicBoolean:
|
||||
bool get() override {
|
||||
return value_.load();
|
||||
}
|
||||
|
||||
// AtomicBoolean:
|
||||
void set(bool value) override {
|
||||
value_.store(value);
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic_bool value_;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_SHARED_ATOMIC_BOOLEAN_IMPL_H_
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "platform/impl/shared/posix_condition_variable.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
PosixConditionVariable::PosixConditionVariable(Ptr<PosixLock> lock)
|
||||
: lock_(lock), attr_(), cond_() {
|
||||
pthread_condattr_init(&attr_);
|
||||
|
||||
pthread_cond_init(&cond_, &attr_);
|
||||
}
|
||||
|
||||
PosixConditionVariable::~PosixConditionVariable() {
|
||||
pthread_cond_destroy(&cond_);
|
||||
|
||||
pthread_condattr_destroy(&attr_);
|
||||
}
|
||||
|
||||
void PosixConditionVariable::notify() { pthread_cond_broadcast(&cond_); }
|
||||
|
||||
Exception::Value PosixConditionVariable::wait() {
|
||||
pthread_cond_wait(&cond_, &(lock_->mutex_));
|
||||
|
||||
return Exception::kSuccess;
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef PLATFORM_IMPL_SHARED_POSIX_CONDITION_VARIABLE_H_
|
||||
#define PLATFORM_IMPL_SHARED_POSIX_CONDITION_VARIABLE_H_
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "platform/api/condition_variable.h"
|
||||
#include "platform/impl/shared/posix_lock.h"
|
||||
#include "platform/ptr.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
class PosixConditionVariable : public ConditionVariable {
|
||||
public:
|
||||
explicit PosixConditionVariable(Ptr<PosixLock> lock);
|
||||
~PosixConditionVariable() override;
|
||||
|
||||
void notify() override;
|
||||
Exception::Value wait() override;
|
||||
|
||||
private:
|
||||
Ptr<PosixLock> lock_;
|
||||
pthread_condattr_t attr_;
|
||||
pthread_cond_t cond_;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_SHARED_POSIX_CONDITION_VARIABLE_H_
|
||||
@@ -1,24 +1,24 @@
|
||||
#include "platform/impl/default/default_lock.h"
|
||||
#include "platform/impl/shared/posix_lock.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
DefaultLock::DefaultLock() : attr_(), mutex_() {
|
||||
PosixLock::PosixLock() : attr_(), mutex_() {
|
||||
pthread_mutexattr_init(&attr_);
|
||||
pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE);
|
||||
|
||||
pthread_mutex_init(&mutex_, &attr_);
|
||||
}
|
||||
|
||||
DefaultLock::~DefaultLock() {
|
||||
PosixLock::~PosixLock() {
|
||||
pthread_mutex_destroy(&mutex_);
|
||||
|
||||
pthread_mutexattr_destroy(&attr_);
|
||||
}
|
||||
|
||||
void DefaultLock::lock() { pthread_mutex_lock(&mutex_); }
|
||||
void PosixLock::lock() { pthread_mutex_lock(&mutex_); }
|
||||
|
||||
void DefaultLock::unlock() { pthread_mutex_unlock(&mutex_); }
|
||||
void PosixLock::unlock() { pthread_mutex_unlock(&mutex_); }
|
||||
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef PLATFORM_IMPL_DEFAULT_DEFAULT_LOCK_H_
|
||||
#define PLATFORM_IMPL_DEFAULT_DEFAULT_LOCK_H_
|
||||
#ifndef PLATFORM_IMPL_SHARED_POSIX_LOCK_H_
|
||||
#define PLATFORM_IMPL_SHARED_POSIX_LOCK_H_
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
|
||||
class DefaultLock : public Lock {
|
||||
class PosixLock : public Lock {
|
||||
public:
|
||||
DefaultLock();
|
||||
~DefaultLock() override;
|
||||
PosixLock();
|
||||
~PosixLock() override;
|
||||
|
||||
void lock() override;
|
||||
void unlock() override;
|
||||
|
||||
private:
|
||||
friend class DefaultConditionVariable;
|
||||
friend class PosixConditionVariable;
|
||||
|
||||
pthread_mutexattr_t attr_;
|
||||
pthread_mutex_t mutex_;
|
||||
@@ -26,4 +26,4 @@ class DefaultLock : public Lock {
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_DEFAULT_DEFAULT_LOCK_H_
|
||||
#endif // PLATFORM_IMPL_SHARED_POSIX_LOCK_H_
|
||||
@@ -0,0 +1,22 @@
|
||||
cc_library(
|
||||
name = "sample_wifi_medium",
|
||||
srcs = [
|
||||
"sample_wifi_medium.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"sample_wifi_medium.h",
|
||||
],
|
||||
visibility = [
|
||||
"//googlemac/iPhone/Shared/Nearby/Connections:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
"//platform/impl:__subpackages__",
|
||||
"//location/nearby/setup/core:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//platform:types",
|
||||
"//platform:utils",
|
||||
"//platform/api",
|
||||
"//platform/port:string",
|
||||
"//absl/time",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
add_library(platform_impl_shared_sample STATIC)
|
||||
|
||||
target_sources(platform_impl_shared_sample
|
||||
PRIVATE
|
||||
sample_wifi_medium.cc
|
||||
PUBLIC
|
||||
sample_wifi_medium.h
|
||||
)
|
||||
|
||||
target_link_libraries(platform_impl_shared_sample
|
||||
PUBLIC
|
||||
absl::time
|
||||
platform_api
|
||||
platform_port_string
|
||||
platform_types
|
||||
platform_utils
|
||||
)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include "platform/impl/sample/sample_wifi_medium.h"
|
||||
#include "platform/impl/shared/sample/sample_wifi_medium.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
#ifndef PLATFORM_IMPL_SAMPLE_SAMPLE_WIFI_MEDIUM_H_
|
||||
#define PLATFORM_IMPL_SAMPLE_SAMPLE_WIFI_MEDIUM_H_
|
||||
#ifndef PLATFORM_IMPL_SHARED_SAMPLE_SAMPLE_WIFI_MEDIUM_H_
|
||||
#define PLATFORM_IMPL_SHARED_SAMPLE_SAMPLE_WIFI_MEDIUM_H_
|
||||
|
||||
#include "platform/api/wifi.h"
|
||||
|
||||
@@ -56,4 +56,4 @@ class SampleWifiMedium : public WifiMedium {
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
|
||||
#endif // PLATFORM_IMPL_SAMPLE_SAMPLE_WIFI_MEDIUM_H_
|
||||
#endif // PLATFORM_IMPL_SHARED_SAMPLE_SAMPLE_WIFI_MEDIUM_H_
|
||||
Reference in New Issue
Block a user