CMS 3D CMS Logo

WaitingTaskWithArenaHolder.h
Go to the documentation of this file.
1 #ifndef FWCore_Concurrency_WaitingTaskWithArenaHolder_h
2 #define FWCore_Concurrency_WaitingTaskWithArenaHolder_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Concurrency
6 // Class : WaitingTaskWithArenaHolder
7 //
17 //
18 // Original Author: W. David Dagenhart
19 // Created: 9 November 2017
20 //
21 
22 #include <exception>
23 #include <memory>
24 
25 #include "tbb/task_arena.h"
26 
27 namespace edm {
28 
29  class WaitingTask;
30  class WaitingTaskHolder;
31 
33  public:
35 
36  // Note that the arena will be the one containing the thread
37  // that runs this constructor. This is the arena where you
38  // eventually intend for the task to be spawned.
39  explicit WaitingTaskWithArenaHolder(WaitingTask* iTask);
40 
42 
44 
46 
48 
50 
51  // This spawns the task. The arena is needed to get the task spawned
52  // into the correct arena of threads. Use of the arena allows doneWaiting
53  // to be called from a thread outside the arena of threads that will manage
54  // the task. doneWaiting can be called from a non-TBB thread.
55  void doneWaiting(std::exception_ptr iExcept);
56 
57  // This next function is useful if you know from the context that
58  // m_arena (which is set when the constructor was executes) is the
59  // same arena in which you want to execute the doneWaiting function.
60  // It allows an optimization which avoids the enqueue step in the
61  // doneWaiting function.
62  //
63  // Be warned though that in general this function cannot be used.
64  // Spawning a task outside the correct arena could create a new separate
65  // arena with its own extra TBB worker threads if this function is used
66  // in an inappropriate context (and silently such that you might not notice
67  // the problem quickly).
69 
70  private:
71  // ---------- member data --------------------------------
73  std::shared_ptr<tbb::task_arena> m_arena;
74  };
75 } // namespace edm
76 #endif
WaitingTaskWithArenaHolder & operator=(const WaitingTaskWithArenaHolder &iRHS)
void doneWaiting(std::exception_ptr iExcept)
HLT enums.
std::shared_ptr< tbb::task_arena > m_arena