Commit 3da9625c authored by tqcq's avatar tqcq
Browse files

feat update

parent 7100bcf1
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -54,14 +54,6 @@ private:
    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>>
std::function<InvokeResultT<F, Args...>(Args &&...)>
SafeTask(scoped_refptr<PendingTaskSafetyFlag> flag, F &&f)
+12 −9
Original line number Diff line number Diff line
@@ -86,8 +86,11 @@ TimerManager::CreateTimer(const std::string &name, Timer::OnExpired on_expired)

    std::unique_ptr<Timeout> timeout = timeout_creator_(sled::TaskQueueBase::DelayPrecision::kHigh);
    auto timer                       = std::unique_ptr<Timer>(new Timer(
        id, name, std::move(on_expired),
        /* ungrgister_handler=*/[this, id]() { timers_.erase(id); }, std::move(timeout)));
        id,
        name,
        std::move(on_expired),
        /* ungrgister_handler=*/[this, id]() { timers_.erase(id); },
        std::move(timeout)));
    timers_[id]                      = timer.get();
    return timer;
}