Logo ROOT   6.12/07
Reference Guide
TTaskGroup.hxx
Go to the documentation of this file.
1 // @(#)root/thread:$Id$
2 // Author: Danilo Piparo August 2017
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TTaskGroup
13 #define ROOT_TTaskGroup
14 
15 #include <atomic>
16 #include <functional>
17 
18 namespace ROOT {
19 namespace Experimental {
20 
21 class TTaskGroup {
22  /**
23  \class ROOT::Experimental::TTaskGroup
24  \ingroup Parallelism
25  \brief A class to manage the asynchronous execution of work items.
26 
27  A TTaskGroup represents concurrent execution of a group of tasks. Tasks may be dynamically added to the group as it
28  is executing.
29  */
30 private:
31  using TaskContainerPtr_t = void *; /// Shield completely from implementation
33  std::atomic<bool> fCanRun{true};
34 
35 public:
36  TTaskGroup();
37  TTaskGroup(TTaskGroup &&other);
38  TTaskGroup(const TTaskGroup &) = delete;
40  ~TTaskGroup();
41 
42  void Cancel();
43  void Run(const std::function<void(void)> &closure);
44  void Wait();
45 };
46 }
47 }
48 
49 #endif
TTaskGroup & operator=(TTaskGroup &&other)
Definition: TTaskGroup.cxx:55
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
void Wait()
Wait until all submitted items of work are completed.
Definition: TTaskGroup.cxx:107
std::atomic< bool > fCanRun
Definition: TTaskGroup.hxx:33
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:146
A class to manage the asynchronous execution of work items.
Definition: TTaskGroup.hxx:21
void Run(const std::function< void(void)> &closure)
Add to the group an item of work which will be ran asynchronously.
Definition: TTaskGroup.cxx:92
void Cancel()
Cancel all submitted tasks immediately.
Definition: TTaskGroup.cxx:75
TaskContainerPtr_t fTaskContainer
Shield completely from implementation.
Definition: TTaskGroup.hxx:32