user-defined expirations
[folly.git] / folly / experimental / wangle / concurrent / CPUThreadPoolExecutor.h
index 7811c6783f81c2b1a660c8cdf018f6a6a4ca9618..28e2dad6e85b9b0850ed9dcf43254962d702a49c 100644 (file)
@@ -34,11 +34,22 @@ class CPUThreadPoolExecutor : public ThreadPoolExecutor {
   ~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;