Roll forward to cl/318932159

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: Ic18f5d83a59deaf81afec14dcf2187b8c70195eb
This commit is contained in:
Alexey Polyudov
2020-06-30 00:31:15 -07:00
parent 3e5ca324f1
commit 31ab07b5d7
39 changed files with 1229 additions and 189 deletions
-1
View File
@@ -45,7 +45,6 @@ cc_library(
"//absl/base:core_headers",
"//absl/synchronization",
"//absl/time",
"//absl/types:any",
"//thread",
],
)
+2 -3
View File
@@ -34,9 +34,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(); }
@@ -47,6 +47,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));
+5
View File
@@ -61,6 +61,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>();
@@ -45,6 +45,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_;
};
+1
View File
@@ -65,5 +65,6 @@ cc_test(
"//file/util:temp_path",
"//platform_v2/base",
"//testing/base/public:gunit_main",
"//absl/strings",
],
)
+2 -1
View File
@@ -22,6 +22,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 {
@@ -36,7 +37,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();