mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-15 07:06:11 -04:00
Merge branch 'google3'
Change-Id: Ic0929c69225dba30ae0aa9bec2d5ce155fd927c0
This commit is contained in:
@@ -31,7 +31,6 @@ cc_library(
|
||||
"//absl/base:core_headers",
|
||||
"//absl/synchronization",
|
||||
"//absl/time",
|
||||
"//absl/types:any",
|
||||
"//thread",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -20,9 +20,8 @@ class ConditionVariable : public api::ConditionVariable {
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
Exception Wait(absl::Duration timeout) override {
|
||||
return cond_var_.WaitWithTimeout(mutex_, timeout)
|
||||
? Exception{Exception::kTimeout}
|
||||
: Exception{Exception::kSuccess};
|
||||
cond_var_.WaitWithTimeout(mutex_, timeout);
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
void Notify() override { cond_var_.SignalAll(); }
|
||||
|
||||
|
||||
@@ -33,6 +33,11 @@ class MultiThreadExecutor : public api::SubmittableExecutor {
|
||||
void Shutdown() override { DoShutdown(); }
|
||||
~MultiThreadExecutor() override { DoShutdown(); }
|
||||
|
||||
int GetTid(int index) const override {
|
||||
const auto* thread = thread_pool_.thread(index);
|
||||
return thread ? thread->tid() : 0;
|
||||
}
|
||||
|
||||
void ScheduleAfter(absl::Duration delay, Runnable&& runnable) {
|
||||
if (shutdown_) return;
|
||||
thread_pool_.ScheduleAt(absl::Now() + delay, std::move(runnable));
|
||||
|
||||
@@ -47,6 +47,11 @@ std::string GetPayloadPath(PayloadId payload_id) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int GetCurrentTid() {
|
||||
const LiveThread* my = Thread_GetMyLiveThread();
|
||||
return LiveThread_Pthread_TID(my);
|
||||
}
|
||||
|
||||
std::unique_ptr<SubmittableExecutor>
|
||||
ImplementationPlatform::CreateSingleThreadExecutor() {
|
||||
return absl::make_unique<g3::SingleThreadExecutor>();
|
||||
|
||||
@@ -31,6 +31,9 @@ class ScheduledExecutor final : public api::ScheduledExecutor {
|
||||
absl::Duration delay) override;
|
||||
void Shutdown() override { executor_.Shutdown(); }
|
||||
|
||||
int GetTid(int index) const override {
|
||||
return executor_.GetTid(index);
|
||||
}
|
||||
private:
|
||||
SingleThreadExecutor executor_;
|
||||
};
|
||||
|
||||
@@ -51,5 +51,6 @@ cc_test(
|
||||
"//file/util:temp_path",
|
||||
"//platform_v2/base",
|
||||
"//testing/base/public:gunit_main",
|
||||
"//absl/strings",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "file/util/temp_path.h"
|
||||
#include "platform_v2/base/byte_array.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
@@ -22,7 +23,7 @@ class FileTest : public ::testing::Test {
|
||||
file_ = std::fstream(path_, std::fstream::in | std::fstream::out);
|
||||
}
|
||||
|
||||
void WriteToFile(const std::string& text) {
|
||||
void WriteToFile(absl::string_view text) {
|
||||
file_ << text;
|
||||
file_.flush();
|
||||
size_ += text.size();
|
||||
|
||||
Reference in New Issue
Block a user