Merge branch 'master' into release

Change-Id: Iaeb2144000bba05bf9532a55518b9549d7662361
This commit is contained in:
Alexey Polyudov
2020-06-30 00:29:25 -07:00
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_;
};