feat update
All checks were successful
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 1m45s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 1m51s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 2m18s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m19s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 2m21s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m24s
All checks were successful
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 1m45s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 1m51s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 2m18s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m19s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 2m21s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m24s
This commit is contained in:
parent
7100bcf163
commit
3da9625ce2
@ -54,14 +54,6 @@ private:
|
|||||||
scoped_refptr<PendingTaskSafetyFlag> flag_;
|
scoped_refptr<PendingTaskSafetyFlag> flag_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// inline std::function<void()>
|
|
||||||
// SafeTask(scoped_refptr<PendingTaskSafetyFlag> flag, std::function<void()> task)
|
|
||||||
// {
|
|
||||||
// return [flag, task]() mutable {
|
|
||||||
// if (flag->alive()) { std::move(task)(); }
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
template<typename F, typename... Args, typename = EnableIfT<!std::is_void<InvokeResultT<F, Args...>>::value>>
|
template<typename F, typename... Args, typename = EnableIfT<!std::is_void<InvokeResultT<F, Args...>>::value>>
|
||||||
std::function<InvokeResultT<F, Args...>(Args &&...)>
|
std::function<InvokeResultT<F, Args...>(Args &&...)>
|
||||||
SafeTask(scoped_refptr<PendingTaskSafetyFlag> flag, F &&f)
|
SafeTask(scoped_refptr<PendingTaskSafetyFlag> flag, F &&f)
|
||||||
|
@ -47,9 +47,9 @@ Timer::Stop()
|
|||||||
{
|
{
|
||||||
if (is_running()) {
|
if (is_running()) {
|
||||||
timeout_->Stop();
|
timeout_->Stop();
|
||||||
generation_ = TimerGeneration(generation_ + 1);
|
generation_ = TimerGeneration(generation_ + 1);
|
||||||
expiration_count_ = 0;
|
expiration_count_ = 0;
|
||||||
is_running_ = false;
|
is_running_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,23 +81,26 @@ Timer::Trigger(TimerGeneration generation)
|
|||||||
std::unique_ptr<Timer>
|
std::unique_ptr<Timer>
|
||||||
TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired)
|
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_;
|
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 = std::unique_ptr<Timer>(new Timer(
|
||||||
id, name, std::move(on_expired),
|
id,
|
||||||
/* ungrgister_handler=*/[this, id]() { timers_.erase(id); }, std::move(timeout)));
|
name,
|
||||||
timers_[id] = timer.get();
|
std::move(on_expired),
|
||||||
|
/* ungrgister_handler=*/[this, id]() { timers_.erase(id); },
|
||||||
|
std::move(timeout)));
|
||||||
|
timers_[id] = timer.get();
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimerManager::HandleTimeout(TimeoutID id)
|
TimerManager::HandleTimeout(TimeoutID id)
|
||||||
{
|
{
|
||||||
TimerID timer_id = id >> 32;
|
TimerID timer_id = id >> 32;
|
||||||
TimerGeneration generation = id & 0xffffffff;
|
TimerGeneration generation = id & 0xffffffff;
|
||||||
auto it = timers_.find(timer_id);
|
auto it = timers_.find(timer_id);
|
||||||
if (it != timers_.end()) { it->second->Trigger(generation); }
|
if (it != timers_.end()) { it->second->Trigger(generation); }
|
||||||
}
|
}
|
||||||
}// namespace sled
|
}// namespace sled
|
||||||
|
Loading…
Reference in New Issue
Block a user