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 <memory>
17#include <functional>
18
19namespace ROOT {
20namespace Internal {
21class RTaskArenaWrapper;
22}
23
24namespace Experimental {
25
27 /**
28 \class ROOT::Experimental::TTaskGroup
29 \ingroup Parallelism
30 \brief A class to manage the asynchronous execution of work items.
31
32 A TTaskGroup represents concurrent execution of a group of tasks. Tasks may be dynamically added to the group as it
33 is executing.
34 */
35private:
36 std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> fTaskArenaW;
37 void *fTaskContainer{nullptr};
38 void ExecuteInIsolation(const std::function<void(void)> &operation);
39
40public:
41 TTaskGroup();
42 TTaskGroup(TTaskGroup &&other);
43 TTaskGroup(const TTaskGroup &) = delete;
46
47 void Cancel();
48 void Run(const std::function<void(void)> &closure);
49 void Wait();
50};
51} // namespace Experimental
52} // namespace ROOT
53
54#endif
A class to manage the asynchronous execution of work items.
std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > fTaskArenaW
void ExecuteInIsolation(const std::function< void(void)> &operation)
Run operation in the internal task arena to implement work isolation, i.e.
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)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...