mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 07:36:10 -04:00
Merge branch 'master' into release
Change-Id: Iaeb2144000bba05bf9532a55518b9549d7662361
This commit is contained in:
@@ -45,7 +45,6 @@ cc_library(
|
||||
"//absl/base:core_headers",
|
||||
"//absl/synchronization",
|
||||
"//absl/time",
|
||||
"//absl/types:any",
|
||||
"//thread",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user