Logo ROOT  
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 "ROOT/RTaskArena.hxx"
23#include <atomic>
24
25static std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> &R__GetTaskArena4IMT()
26{
27 static std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> globalTaskArena;
28 return globalTaskArena;
29}
30
32{
34};
35
36static bool &GetImplicitMTFlag()
37{
38 static bool enabled = false;
39 return enabled;
40}
41
42static std::atomic_int &GetParBranchProcessingCount()
43{
44 static std::atomic_int count(0);
45 return count;
46}
47
48extern "C" void ROOT_TImplicitMT_EnableImplicitMT(UInt_t numthreads)
49{
50 if (!GetImplicitMTFlag()) {
52 GetImplicitMTFlag() = true;
53 } else {
54 ::Warning("ROOT_TImplicitMT_EnableImplicitMT", "Implicit multi-threading is already enabled");
55 }
56};
57
59{
60 if (GetImplicitMTFlag()) {
61 GetImplicitMTFlag() = false;
62 R__GetTaskArena4IMT().reset();
63 } else {
64 ::Warning("ROOT_TImplicitMT_DisableImplicitMT", "Implicit multi-threading is already disabled");
65 }
66};
67
69{
71};
72
74{
76};
77
79{
80 return GetParBranchProcessingCount() > 0;
81};
unsigned int UInt_t
Definition: RtypesCore.h:44
void Warning(const char *location, const char *msgfmt,...)
bool ROOT_TImplicitMT_IsParBranchProcessingEnabled()
Definition: TImplicitMT.cxx:78
static std::atomic_int & GetParBranchProcessingCount()
Definition: TImplicitMT.cxx:42
void ROOT_TImplicitMT_DisableParBranchProcessing()
Definition: TImplicitMT.cxx:73
static bool & GetImplicitMTFlag()
Definition: TImplicitMT.cxx:36
void ROOT_TImplicitMT_EnableImplicitMT(UInt_t numthreads)
Definition: TImplicitMT.cxx:48
void ROOT_TImplicitMT_DisableImplicitMT()
Definition: TImplicitMT.cxx:58
static std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > & R__GetTaskArena4IMT()
Definition: TImplicitMT.cxx:25
void ROOT_TImplicitMT_EnableParBranchProcessing()
Definition: TImplicitMT.cxx:68
UInt_t ROOT_MT_GetThreadPoolSize()
Definition: TImplicitMT.cxx:31
std::shared_ptr< ROOT::Internal::RTaskArenaWrapper > GetGlobalTaskArena(unsigned maxConcurrency=0)
Factory function returning a shared pointer to the instance of the global RTaskArenaWrapper.
Definition: RTaskArena.cxx:109