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:
34 
36 
37  // Note that the arena will be the one containing the thread
38  // that runs this constructor. This is the arena where you
39  // eventually intend for the task to be spawned.
40  explicit WaitingTaskWithArenaHolder(WaitingTask* iTask);
41 
43 
45 
47 
49 
51 
52  // This spawns the task. The arena is needed to get the task spawned
53  // into the correct arena of threads. Use of the arena allows doneWaiting
54  // to be called from a thread outside the arena of threads that will manage
55  // the task. doneWaiting can be called from a non-TBB thread.
56  void doneWaiting(std::exception_ptr iExcept);
57 
58  // This next function is useful if you know from the context that
59  // m_arena (which is set when the constructor was executes) is the
60  // same arena in which you want to execute the doneWaiting function.
61  // It allows an optimization which avoids the enqueue step in the
62  // doneWaiting function.
63  //
64  // Be warned though that in general this function cannot be used.
65  // Spawning a task outside the correct arena could create a new separate
66  // arena with its own extra TBB worker threads if this function is used
67  // in an inappropriate context (and silently such that you might not notice
68  // the problem quickly).
70 
71  private:
72 
73  // ---------- member data --------------------------------
75  std::shared_ptr<tbb::task_arena> m_arena;
76  };
77 }
78 #endif
WaitingTaskWithArenaHolder & operator=(const WaitingTaskWithArenaHolder &iRHS)
void doneWaiting(std::exception_ptr iExcept)
HLT enums.
std::shared_ptr< tbb::task_arena > m_arena