Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:55

0001 #ifndef FWCore_Concurrency_FunctorTask_h
0002 #define FWCore_Concurrency_FunctorTask_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Concurrency
0006 // Class  :     FunctorTask
0007 //
0008 /**\class FunctorTask FunctorTask.h FWCore/Concurrency/interface/FunctorTask.h
0009 
0010  Description: Builds a oneapi::tbb::task from a lambda.
0011 
0012  Usage:
0013  
0014 */
0015 //
0016 // Original Author:  Chris Jones
0017 //         Created:  Thu Feb 21 13:46:31 CST 2013
0018 // $Id$
0019 //
0020 
0021 // system include files
0022 #include <atomic>
0023 #include <exception>
0024 #include <memory>
0025 
0026 // user include files
0027 #include "FWCore/Concurrency/interface/TaskBase.h"
0028 
0029 // forward declarations
0030 
0031 namespace edm {
0032   template <typename F>
0033   class FunctorTask : public TaskBase {
0034   public:
0035     explicit FunctorTask(F f) : func_(std::move(f)) {}
0036 
0037     void execute() final { func_(); };
0038 
0039   private:
0040     F func_;
0041   };
0042 
0043   template <typename F>
0044   FunctorTask<F>* make_functor_task(F f) {
0045     return new FunctorTask<F>(std::move(f));
0046   }
0047 }  // namespace edm
0048 
0049 #endif