Doesn't build yet. But did more work to align the older fork with newer APIs.

This commit is contained in:
kidfromjupiter
2025-12-29 13:35:08 +00:00
parent 5f93c46954
commit 6c41d26a86
52 changed files with 279 additions and 289 deletions
@@ -37,7 +37,7 @@ Timer::~Timer() {
absl::MutexLock l(&mutex_);
if (timerid_.has_value())
if (timer_delete(*timerid_) < 0) {
NEARBY_LOGS(ERROR) << __func__ << ": Error deleting POSIX timer: "
LOG(ERROR) << __func__ << ": Error deleting POSIX timer: "
<< std::strerror(errno);
}
}
@@ -45,14 +45,14 @@ Timer::~Timer() {
bool Timer::Create(int delay, int interval,
absl::AnyInvocable<void()> callback) {
if (delay < 0 || interval < 0) {
NEARBY_LOGS(ERROR) << __func__
LOG(ERROR) << __func__
<< ": Delay and interval cannot be negative.";
return false;
}
absl::MutexLock l(&mutex_);
if (timerid_.has_value()) {
NEARBY_LOGS(ERROR) << __func__
LOG(ERROR) << __func__
<< "Timer has already been created and armed.";
return false;
}
@@ -74,16 +74,16 @@ bool Timer::Create(int delay, int interval,
spec.it_interval.tv_sec = 0;
if (timer_create(CLOCK_MONOTONIC, &ev, &timerid) < 0) {
NEARBY_LOGS(ERROR) << __func__ << ": Error creating POSIX timer: "
LOG(ERROR) << __func__ << ": Error creating POSIX timer: "
<< std::strerror(errno);
return false;
}
if (timer_settime(&timerid, 0, &spec, nullptr) < 0) {
NEARBY_LOGS(ERROR) << __func__ << ": Error arming POSIX timer: "
LOG(ERROR) << __func__ << ": Error arming POSIX timer: "
<< std::strerror(errno);
if (!timer_delete(&timerid)) {
NEARBY_LOGS(ERROR) << __func__ << ": error deleting POSIX timer: "
LOG(ERROR) << __func__ << ": error deleting POSIX timer: "
<< std::strerror(errno);
}
return false;
@@ -96,12 +96,12 @@ bool Timer::Create(int delay, int interval,
bool Timer::Stop() {
absl::MutexLock l(&mutex_);
if (!timerid_.has_value()) {
NEARBY_LOGS(WARNING) << __func__ << ": no timer created";
LOG(WARNING) << __func__ << ": no timer created";
return true;
}
if (!timer_delete(&*timerid_)) {
NEARBY_LOGS(ERROR) << __func__ << ": error deleting POSIX timer: "
LOG(ERROR) << __func__ << ": error deleting POSIX timer: "
<< std::strerror(errno);
return false;
}
@@ -111,24 +111,5 @@ bool Timer::Stop() {
return true;
}
bool Timer::FireNow() {
absl::MutexLock lock(&mutex_);
if (!timerid_.has_value()) {
NEARBY_LOGS(ERROR) << __func__ << ": No timer has been created";
return false;
}
if (callback_ == nullptr) {
NEARBY_LOGS(ERROR) << __func__ << ": No callback has been set";
return false;
}
if (task_executor_ == nullptr) {
task_executor_ = std::make_unique<SubmittableExecutor>();
}
task_executor_->Execute([&]() { callback_(); });
return true;
}
} // namespace linux
} // namespace nearby