Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 std::atomic<bool> fCanRun{true};
33 void ExecuteInIsolation(const std::function<void(void)> &operation);
34
35public:
36 TTaskGroup();
37 TTaskGroup(TTaskGroup &&other);
38 TTaskGroup(const TTaskGroup &) = delete;
41
42 void Cancel();
43 void Run(const std::function<void(void)> &closure);
44 void Wait();
45};
46} // namespace Experimental
47} // namespace ROOT
48
49#endif
A class to manage the asynchronous execution of work items.
void ExecuteInIsolation(const std::function< void(void)> &operation)
void Run(const std::function< void(void)> &closure)
Add to the group an item of work which will be ran asynchronously.
void Wait()
Wait until all submitted items of work are completed.
void Cancel()
Cancel all submitted tasks immediately.
TTaskGroup(const TTaskGroup &)=delete
TTaskGroup & operator=(TTaskGroup &&other)
std::atomic< bool > fCanRun
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.