File indexing completed on 2024-06-07 02:29:33
0001 #ifndef FWCore_Concurrency_Async_h
0002 #define FWCore_Concurrency_Async_h
0003
0004 #include "FWCore/Concurrency/interface/WaitingTaskWithArenaHolder.h"
0005 #include "FWCore/Concurrency/interface/WaitingThreadPool.h"
0006
0007 namespace edm {
0008
0009 class Async {
0010 public:
0011 Async() = default;
0012 virtual ~Async() noexcept;
0013
0014
0015 Async(Async const&) = delete;
0016 Async(Async&&) = delete;
0017 Async& operator=(Async const&) = delete;
0018 Async& operator=(Async&&) = delete;
0019
0020 template <typename F, typename G>
0021 void runAsync(WaitingTaskWithArenaHolder holder, F&& func, G&& errorContextFunc) {
0022 ensureAllowed();
0023 pool_.runAsync(std::move(holder), std::forward<F>(func), std::forward<G>(errorContextFunc));
0024 }
0025
0026 protected:
0027 virtual void ensureAllowed() const = 0;
0028
0029 private:
0030 WaitingThreadPool pool_;
0031 };
0032 }
0033
0034 #endif