Loading src/sled/timer/timer.cc +8 −6 Original line number Diff line number Diff line Loading @@ -109,21 +109,23 @@ Timer::Trigger(TimerGeneration generation) } } std::unique_ptr<Timer> TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired) std::unique_ptr<Timer, TimerThreadDeleter> TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired, TaskQueueBase *owner) { next_id_ = TimerID(next_id_ + 1); TimerID id = next_id_; std::unique_ptr<Timeout> timeout = timeout_creator_(sled::TaskQueueBase::DelayPrecision::kHigh); auto timer = std::unique_ptr<Timer>(new Timer( auto timer = new Timer( id, name, std::move(on_expired), /* ungrgister_handler=*/[this, id]() { timers_.erase(id); }, std::move(timeout))); timers_[id] = timer.get(); return timer; std::move(timeout)); auto unique_timer = std::unique_ptr<Timer, TimerThreadDeleter>(timer, TimerThreadDeleter(owner)); timers_[id] = unique_timer.get(); return unique_timer; } void Loading src/sled/timer/timer.h +2 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,8 @@ class TimerManager { public: explicit TimerManager(TimeoutCreator timeout_creator) : timeout_creator_(timeout_creator) {} std::unique_ptr<Timer> CreateTimer(const std::string &name, Timer::OnExpired on_expired); std::unique_ptr<Timer, TimerThreadDeleter> CreateTimer(const std::string &name, Timer::OnExpired on_expired, TaskQueueBase *owner = nullptr); void HandleTimeout(TimeoutID timeout_id); private: Loading Loading
src/sled/timer/timer.cc +8 −6 Original line number Diff line number Diff line Loading @@ -109,21 +109,23 @@ Timer::Trigger(TimerGeneration generation) } } std::unique_ptr<Timer> TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired) std::unique_ptr<Timer, TimerThreadDeleter> TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired, TaskQueueBase *owner) { next_id_ = TimerID(next_id_ + 1); TimerID id = next_id_; std::unique_ptr<Timeout> timeout = timeout_creator_(sled::TaskQueueBase::DelayPrecision::kHigh); auto timer = std::unique_ptr<Timer>(new Timer( auto timer = new Timer( id, name, std::move(on_expired), /* ungrgister_handler=*/[this, id]() { timers_.erase(id); }, std::move(timeout))); timers_[id] = timer.get(); return timer; std::move(timeout)); auto unique_timer = std::unique_ptr<Timer, TimerThreadDeleter>(timer, TimerThreadDeleter(owner)); timers_[id] = unique_timer.get(); return unique_timer; } void Loading
src/sled/timer/timer.h +2 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,8 @@ class TimerManager { public: explicit TimerManager(TimeoutCreator timeout_creator) : timeout_creator_(timeout_creator) {} std::unique_ptr<Timer> CreateTimer(const std::string &name, Timer::OnExpired on_expired); std::unique_ptr<Timer, TimerThreadDeleter> CreateTimer(const std::string &name, Timer::OnExpired on_expired, TaskQueueBase *owner = nullptr); void HandleTimeout(TimeoutID timeout_id); private: Loading