Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBranchIMTHelper.h
Go to the documentation of this file.
1// @(#)root/tree:$Id$
2// Author: Brian Bockelman, 2017
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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#ifndef ROOT_TBranchIMTHelper
13#define ROOT_TBranchIMTHelper
14
15#include "RtypesCore.h"
16
17#ifdef R__USE_IMT
18#include "ROOT/TTaskGroup.hxx"
19#endif
20
21/** \class ROOT::Internal::TBranchIMTHelper
22 A helper class for managing IMT work during TTree:Fill operations.
23*/
24
25namespace ROOT {
26namespace Internal {
27
29
30#ifdef R__USE_IMT
32#endif
33
34public:
35 template<typename FN> void Run(const FN &lambda) {
36#ifdef R__USE_IMT
37 if (!fGroup) { fGroup.reset(new TaskGroup_t()); }
38 fGroup->Run( [=]() {
39 auto nbytes = lambda();
40 if (nbytes >= 0) {
41 fBytes += nbytes;
42 } else {
43 ++fNerrors;
44 }
45 });
46#else
47 (void)lambda;
48#endif
49 }
50
51 void Wait() {
52#ifdef R__USE_IMT
53 if (fGroup) fGroup->Wait();
54#endif
55 }
56
59
60private:
61 std::atomic<Long64_t> fBytes{0}; ///< Total number of bytes written by this helper.
62 std::atomic<Int_t> fNerrors{0}; ///< Total error count of all tasks done by this helper.
63#ifdef R__USE_IMT
64 std::unique_ptr<TaskGroup_t> fGroup;
65#endif
66};
67
68} // Internal
69} // ROOT
70
71#endif
long long Long64_t
Definition RtypesCore.h:73
typedef void((*Func_t)())
A class to manage the asynchronous execution of work items.
A helper class for managing IMT work during TTree:Fill operations.
std::unique_ptr< TaskGroup_t > fGroup
std::atomic< Long64_t > fBytes
Total number of bytes written by this helper.
ROOT::Experimental::TTaskGroup TaskGroup_t
std::atomic< Int_t > fNerrors
Total error count of all tasks done by this helper.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...