Logo ROOT   6.16/01
Reference Guide
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#include "ROOT/TPoolManager.hxx"
24#include <atomic>
25
26static std::shared_ptr<ROOT::Internal::TPoolManager> &R__GetPoolManagerMT()
27{
28 static std::shared_ptr<ROOT::Internal::TPoolManager> schedMT;
29 return schedMT;
30}
31
32static bool &GetImplicitMTFlag()
33{
34 static bool enabled = false;
35 return enabled;
36}
37
38static std::atomic_int &GetParBranchProcessingCount()
39{
40 static std::atomic_int count(0);
41 return count;
42}
43
44static std::atomic_int &GetParTreeProcessingCount()
45{
46 static std::atomic_int count(0);
47 return count;
48}
49
50extern "C" void ROOT_TImplicitMT_EnableImplicitMT(UInt_t numthreads)
51{
52 if (!GetImplicitMTFlag()) {
55 }
57 GetImplicitMTFlag() = true;
58 } else {
59 ::Warning("ROOT_TImplicitMT_EnableImplicitMT", "Implicit multi-threading is already enabled");
60 }
61};
62
64{
65 if (GetImplicitMTFlag()) {
66 GetImplicitMTFlag() = false;
67 R__GetPoolManagerMT().reset();
68 } else {
69 ::Warning("ROOT_TImplicitMT_DisableImplicitMT", "Implicit multi-threading is already disabled");
70 }
71};
72
74{
76};
77
78
80{
82};
83
85{
87};
88
90{
91 return GetParBranchProcessingCount() > 0;
92};
93
95{
97};
98
100{
102};
103
105{
106 return GetParTreeProcessingCount() > 0;
107};
unsigned int UInt_t
Definition: RtypesCore.h:42
void Warning(const char *location, const char *msgfmt,...)
UInt_t ROOT_TImplicitMT_GetImplicitMTPoolSize()
Definition: TImplicitMT.cxx:73
bool ROOT_TImplicitMT_IsParBranchProcessingEnabled()
Definition: TImplicitMT.cxx:89
bool ROOT_TImplicitMT_IsParTreeProcessingEnabled()
static std::atomic_int & GetParBranchProcessingCount()
Definition: TImplicitMT.cxx:38
void ROOT_TImplicitMT_DisableParBranchProcessing()
Definition: TImplicitMT.cxx:84
static bool & GetImplicitMTFlag()
Definition: TImplicitMT.cxx:32
static std::atomic_int & GetParTreeProcessingCount()
Definition: TImplicitMT.cxx:44
void ROOT_TImplicitMT_EnableParTreeProcessing()
Definition: TImplicitMT.cxx:94
void ROOT_TImplicitMT_DisableParTreeProcessing()
Definition: TImplicitMT.cxx:99
void ROOT_TImplicitMT_EnableImplicitMT(UInt_t numthreads)
Definition: TImplicitMT.cxx:50
static std::shared_ptr< ROOT::Internal::TPoolManager > & R__GetPoolManagerMT()
Definition: TImplicitMT.cxx:26
void ROOT_TImplicitMT_DisableImplicitMT()
Definition: TImplicitMT.cxx:63
void ROOT_TImplicitMT_EnableParBranchProcessing()
Definition: TImplicitMT.cxx:79
static UInt_t GetPoolSize()
Returns the number of threads running when the scheduler has been instantiated within ROOT.
static void Initialize()
Initialize the Thread package.
Definition: TThread.cxx:297
std::shared_ptr< TPoolManager > GetPoolManager(UInt_t nThreads=0)
Get a shared pointer to the manager.