diff --git a/src/sled/task_queue/pending_task_safety_flag.h b/src/sled/task_queue/pending_task_safety_flag.h index 00b326b..502cdaa 100644 --- a/src/sled/task_queue/pending_task_safety_flag.h +++ b/src/sled/task_queue/pending_task_safety_flag.h @@ -54,14 +54,6 @@ private: scoped_refptr flag_; }; -// inline std::function -// SafeTask(scoped_refptr flag, std::function task) -// { -// return [flag, task]() mutable { -// if (flag->alive()) { std::move(task)(); } -// }; -// } - template>::value>> std::function(Args &&...)> SafeTask(scoped_refptr flag, F &&f) diff --git a/src/sled/timer/timer.cc b/src/sled/timer/timer.cc index 12cfff1..a6df078 100644 --- a/src/sled/timer/timer.cc +++ b/src/sled/timer/timer.cc @@ -47,9 +47,9 @@ Timer::Stop() { if (is_running()) { timeout_->Stop(); - generation_ = TimerGeneration(generation_ + 1); + generation_ = TimerGeneration(generation_ + 1); expiration_count_ = 0; - is_running_ = false; + is_running_ = false; } } @@ -81,23 +81,26 @@ Timer::Trigger(TimerGeneration generation) std::unique_ptr TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired) { - next_id_ = TimerID(next_id_ + 1); + next_id_ = TimerID(next_id_ + 1); TimerID id = next_id_; std::unique_ptr timeout = timeout_creator_(sled::TaskQueueBase::DelayPrecision::kHigh); - auto timer = std::unique_ptr(new Timer( - id, name, std::move(on_expired), - /* ungrgister_handler=*/[this, id]() { timers_.erase(id); }, std::move(timeout))); - timers_[id] = timer.get(); + auto timer = std::unique_ptr(new Timer( + id, + name, + std::move(on_expired), + /* ungrgister_handler=*/[this, id]() { timers_.erase(id); }, + std::move(timeout))); + timers_[id] = timer.get(); return timer; } void TimerManager::HandleTimeout(TimeoutID id) { - TimerID timer_id = id >> 32; + TimerID timer_id = id >> 32; TimerGeneration generation = id & 0xffffffff; - auto it = timers_.find(timer_id); + auto it = timers_.find(timer_id); if (it != timers_.end()) { it->second->Trigger(generation); } } }// namespace sled