Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//==========================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================
#include "tbb/tbb.h"
#include <iostream>
using namespace tbb;
using namespace std;
class say_hello {
int cnt = 0;
const char* message;
public:
say_hello(const char* str, int i) : message(str), cnt(i) { }
void operator( ) ( ) const {
cout << message << " " << cnt << endl;
}
};
int main( )
{
task_scheduler_init init(2);
task_group tg1, tg2, tg3;
for(int i=0; i<200; ++i) {
tg1.run(std::move(say_hello("child(1)",i)));
tg2.run(std::move(say_hello("child(2)",i)));
tg3.run(std::move(say_hello("child(3)",i)));
}
tg1.wait( ); // wait for tasks to complete
tg2.wait( ); // wait for tasks to complete
tg3.wait( ); // wait for tasks to complete
}