feat support build thread deleter with timer
Some checks failed
linux-x64-gcc / linux-gcc (Debug) (push) Has been cancelled
linux-arm-gcc / linux-gcc-armhf (push) Has been cancelled
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Has been cancelled
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Has been cancelled
linux-x64-gcc / linux-gcc (Release) (push) Has been cancelled
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Has been cancelled
Some checks failed
linux-x64-gcc / linux-gcc (Debug) (push) Has been cancelled
linux-arm-gcc / linux-gcc-armhf (push) Has been cancelled
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Has been cancelled
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Has been cancelled
linux-x64-gcc / linux-gcc (Release) (push) Has been cancelled
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Has been cancelled
This commit is contained in:
parent
216a5c1d99
commit
e730d57cd0
@ -109,21 +109,23 @@ Timer::Trigger(TimerGeneration generation)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Timer>
|
std::unique_ptr<Timer, TimerThreadDeleter>
|
||||||
TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired)
|
TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired, TaskQueueBase *owner)
|
||||||
{
|
{
|
||||||
next_id_ = TimerID(next_id_ + 1);
|
next_id_ = TimerID(next_id_ + 1);
|
||||||
TimerID id = next_id_;
|
TimerID id = next_id_;
|
||||||
|
|
||||||
std::unique_ptr<Timeout> timeout = timeout_creator_(sled::TaskQueueBase::DelayPrecision::kHigh);
|
std::unique_ptr<Timeout> timeout = timeout_creator_(sled::TaskQueueBase::DelayPrecision::kHigh);
|
||||||
auto timer = std::unique_ptr<Timer>(new Timer(
|
auto timer = new Timer(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
std::move(on_expired),
|
std::move(on_expired),
|
||||||
/* ungrgister_handler=*/[this, id]() { timers_.erase(id); },
|
/* ungrgister_handler=*/[this, id]() { timers_.erase(id); },
|
||||||
std::move(timeout)));
|
std::move(timeout));
|
||||||
timers_[id] = timer.get();
|
auto unique_timer = std::unique_ptr<Timer, TimerThreadDeleter>(timer, TimerThreadDeleter(owner));
|
||||||
return timer;
|
|
||||||
|
timers_[id] = unique_timer.get();
|
||||||
|
return unique_timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -73,7 +73,8 @@ class TimerManager {
|
|||||||
public:
|
public:
|
||||||
explicit TimerManager(TimeoutCreator timeout_creator) : timeout_creator_(timeout_creator) {}
|
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);
|
void HandleTimeout(TimeoutID timeout_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user