Logo ROOT   6.12/07
Reference Guide
mt301_TTaskGroupSimple.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_multicore
3 /// \notebook -js
4 /// Shows how to run items of work asynchronously with a TTaskGroup.
5 ///
6 /// \macro_code
7 ///
8 /// \date August 2017
9 /// \author Danilo Piparo
10 
11 
12 void workItem0()
13 {
14  printf("Running workItem0...\n");
15 }
16 
17 void mt301_TTaskGroupSimple()
18 {
19 
21 
22  // Create the task group and give work to it
24 
25  tg.Run(workItem0);
26  tg.Run([](){printf("Running workItem1...\n");});
27 
28  printf("Running something in the \"main\" thread\n");
29 
30  // Wait until all items are complete
31  tg.Wait();
32 
33  printf("All work completed.\n");
34 
35 }
void Wait()
Wait until all submitted items of work are completed.
Definition: TTaskGroup.cxx:107
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
Definition: TROOT.cxx:555
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