~CPUThreadPoolExecutor();
void add(Func func) override;
+ void add(
+ Func func,
+ std::chrono::milliseconds expiration,
+ Func expireCallback = nullptr) override;
struct CPUTask : public ThreadPoolExecutor::Task {
// Must be noexcept move constructible so it can be used in MPMCQueue
- explicit CPUTask(Func&& f) : Task(std::move(f)), poison(false) {}
- CPUTask() : Task(nullptr), poison(true) {}
+ explicit CPUTask(
+ Func&& f,
+ std::chrono::milliseconds expiration,
+ Func&& expireCallback)
+ : Task(std::move(f), expiration, std::move(expireCallback)),
+ poison(false) {}
+ CPUTask()
+ : Task(nullptr, std::chrono::milliseconds(0), nullptr),
+ poison(true) {}
CPUTask(CPUTask&& o) noexcept : Task(std::move(o)), poison(o.poison) {}
CPUTask(const CPUTask&) = default;
CPUTask& operator=(const CPUTask&) = default;