ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TImplicitMT.cxx
Go to the documentation of this file.
1 // @(#)root/thread:$Id$
2 // // Author: Enric Tejedor Saavedra 03/12/15
3 //
4 /*************************************************************************
5  * Copyright (C) 1995-2015, 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 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TImplicitMT //
15 // //
16 // This file implements the methods to enable, disable and check the //
17 // status of the global implicit multi-threading in ROOT. //
18 // //
19 //////////////////////////////////////////////////////////////////////////
20 
21 #include "TError.h"
22 #include "TThread.h"
23 
24 #include "tbb/task_scheduler_init.h"
25 
26 
27 static tbb::task_scheduler_init &GetScheduler()
28 {
29  static tbb::task_scheduler_init scheduler(tbb::task_scheduler_init::deferred);
30  return scheduler;
31 }
32 
33 extern "C" void ROOT_TImplicitMT_EnableImplicitMT(UInt_t numthreads)
34 {
35  if (!GetScheduler().is_active()) {
37 
38  if (numthreads == 0)
39  numthreads = tbb::task_scheduler_init::automatic;
40 
41  GetScheduler().initialize(numthreads);
42  }
43  else {
44  ::Warning("ROOT_TImplicitMT_EnableImplicitMT", "Implicit multi-threading is already enabled");
45  }
46 };
47 
49 {
50  if (GetScheduler().is_active()) {
51  GetScheduler().terminate();
52  }
53  else {
54  ::Warning("ROOT_TImplicitMT_DisableImplicitMT", "Implicit multi-threading is already disabled");
55  }
56 };
57 
59 {
60  return GetScheduler().is_active();
61 };
62 
static void Initialize()
Initialize the Thread package.
Definition: TThread.cxx:296
bool ROOT_TImplicitMT_IsImplicitMTEnabled()
Definition: TImplicitMT.cxx:58
static tbb::task_scheduler_init & GetScheduler()
Definition: TImplicitMT.cxx:27
unsigned int UInt_t
Definition: RtypesCore.h:42
void Warning(const char *location, const char *msgfmt,...)
void ROOT_TImplicitMT_DisableImplicitMT()
Definition: TImplicitMT.cxx:48
void ROOT_TImplicitMT_EnableImplicitMT(UInt_t numthreads)
Definition: TImplicitMT.cxx:33