Logo ROOT   6.16/01
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
18namespace ROOT {
19namespace Experimental {
20
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 */
30private:
31 void *fTaskContainer{nullptr};
32 void *fTaskArena{nullptr};
33 std::atomic<bool> fCanRun{true};
34 void ExecuteInIsolation(const std::function<void(void)> &operation);
35
36public:
37 TTaskGroup();
38 TTaskGroup(TTaskGroup &&other);
39 TTaskGroup(const TTaskGroup &) = delete;
42
43 void Cancel();
44 void Run(const std::function<void(void)> &closure);
45 void Wait();
46};
47} // namespace Experimental
48} // namespace ROOT
49
50#endif
A class to manage the asynchronous execution of work items.
Definition: TTaskGroup.hxx:21
void ExecuteInIsolation(const std::function< void(void)> &operation)
Run operation in the internal task arena to implement work isolation, i.e.
Definition: TTaskGroup.cxx:100
void Run(const std::function< void(void)> &closure)
Add to the group an item of work which will be ran asynchronously.
Definition: TTaskGroup.cxx:128
void Wait()
Wait until all submitted items of work are completed.
Definition: TTaskGroup.cxx:143
void Cancel()
Cancel all submitted tasks immediately.
Definition: TTaskGroup.cxx:111
TTaskGroup(const TTaskGroup &)=delete
TTaskGroup & operator=(TTaskGroup &&other)
Definition: TTaskGroup.cxx:76
std::atomic< bool > fCanRun
Definition: TTaskGroup.hxx:33
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21