-
Notifications
You must be signed in to change notification settings - Fork 35
/
FunctorTask.h
49 lines (38 loc) · 921 Bytes
/
FunctorTask.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef FWCore_Concurrency_FunctorTask_h
#define FWCore_Concurrency_FunctorTask_h
// -*- C++ -*-
//
// Package: Concurrency
// Class : FunctorTask
//
/**\class FunctorTask FunctorTask.h FWCore/Concurrency/interface/FunctorTask.h
Description: Builds a tbb::task from a lambda.
Usage:
*/
//
// Original Author: Chris Jones
// Created: Thu Feb 21 13:46:31 CST 2013
// $Id$
//
// system include files
#include <atomic>
#include <exception>
#include <memory>
// user include files
#include "Framework/TaskBase.h"
// forward declarations
namespace edm {
template <typename F>
class FunctorTask : public TaskBase {
public:
explicit FunctorTask(F f) : func_(std::move(f)) {}
void execute() final { func_(); };
private:
F func_;
};
template <typename F>
FunctorTask<F>* make_functor_task(F f) {
return new FunctorTask<F>(std::move(f));
}
} // namespace edm
#endif