mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Internal bug fix
PiperOrigin-RevId: 522474442
This commit is contained in:
committed by
Copybara-Service
parent
5d4cf93aed
commit
87e044fa89
@@ -49,6 +49,7 @@ cc_library(
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:logging",
|
||||
"//internal/platform/implementation:types",
|
||||
"//internal/platform/implementation/windows:comm",
|
||||
"//internal/platform/implementation/windows/generated:types",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
"@com_google_absl//absl/synchronization",
|
||||
|
||||
@@ -92,7 +92,18 @@ bool Timer::FireNow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
callback_();
|
||||
if (task_executor_ == nullptr) {
|
||||
task_executor_ = std::make_unique<SubmittableExecutor>();
|
||||
}
|
||||
|
||||
if (task_executor_ == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
<< "Failed to fire the task due to cannot create executor.";
|
||||
return false;
|
||||
}
|
||||
|
||||
task_executor_->Execute([&]() { callback_(); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "absl/base/thread_annotations.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "internal/platform/implementation/timer.h"
|
||||
#include "internal/platform/implementation/windows/submittable_executor.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace windows {
|
||||
@@ -43,9 +44,11 @@ class Timer : public api::Timer {
|
||||
mutable absl::Mutex mutex_;
|
||||
int delay_ ABSL_GUARDED_BY(mutex_);
|
||||
int interval_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::AnyInvocable<void()> callback_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::AnyInvocable<void()> callback_;
|
||||
HANDLE handle_ ABSL_GUARDED_BY(mutex_) = nullptr;
|
||||
HANDLE timer_queue_handle_ ABSL_GUARDED_BY(mutex_) = nullptr;
|
||||
std::unique_ptr<SubmittableExecutor> task_executor_ ABSL_GUARDED_BY(mutex_) =
|
||||
nullptr;
|
||||
};
|
||||
|
||||
} // namespace windows
|
||||
|
||||
Reference in New Issue
Block a user