CMS 3D CMS Logo

FinalWaitingTask.h
Go to the documentation of this file.
1 #ifndef FWCore_Concurrency_FinalWaitingTask_h
2 #define FWCore_Concurrency_FinalWaitingTask_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Concurrency
6 // Class : FinalWaitingTask
7 //
18 //
19 // Original Author: Christopher Jones
20 // Created: Tue, 12 Jul 2022 18:45:15 GMT
21 //
22 
23 // system include files
24 #include "oneapi/tbb/task_group.h"
25 
26 // user include files
28 
29 // forward declarations
30 namespace edm {
31  class FinalWaitingTask : public WaitingTask {
32  public:
33  FinalWaitingTask() = delete;
34  explicit FinalWaitingTask(tbb::task_group& iGroup)
35  : m_group{&iGroup}, m_handle{iGroup.defer([]() {})}, m_done{false} {}
36 
37  void execute() final { m_done = true; }
38 
39  [[nodiscard]] bool done() const noexcept { return m_done.load(); }
40 
41  void wait() {
42  m_group->wait();
43  if (exceptionPtr()) {
44  std::rethrow_exception(exceptionPtr());
45  }
46  }
47  std::exception_ptr waitNoThrow() {
48  m_group->wait();
49  return exceptionPtr();
50  }
51 
52  private:
53  void recycle() final { m_group->run(std::move(m_handle)); }
54  tbb::task_group* m_group;
55  tbb::task_handle m_handle;
56  std::atomic<bool> m_done;
57  };
58 
59 } // namespace edm
60 #endif
bool done() const noexcept
std::exception_ptr exceptionPtr() const
Returns exception thrown by dependent task.
Definition: WaitingTask.h:51
std::exception_ptr waitNoThrow()
tbb::task_handle m_handle
FinalWaitingTask(tbb::task_group &iGroup)
std::atomic< bool > m_done
HLT enums.
def move(src, dest)
Definition: eostools.py:511
tbb::task_group * m_group