Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 void workItem0()
12 {
13  printf("Running workItem0...\n");
14 }
15 
16 void mt301_TTaskGroupSimple()
17 {
18 
19  ROOT::EnableImplicitMT(4);
20 
21  // Create the task group and give work to it
22  ROOT::Experimental::TTaskGroup tg;
23 
24  tg.Run(workItem0);
25  tg.Run([]() { printf("Running workItem1...\n"); });
26 
27  printf("Running something in the \"main\" thread\n");
28 
29  // Wait until all items are complete
30  tg.Wait();
31 
32  printf("All work completed.\n");
33 }