<commit_before>// @(#)root/tree:$Id$
// Author: <NAME>, 2017

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TBranchIMTHelper
#define ROOT_TBranchIMTHelper

#include "Rtypes.h"

#ifdef R__USE_IMT
#include "tbb/task_group.h"
#endif

/// A helper class for managing IMT work during TTree:Fill operations.
///
namespace ROOT {
namespace Internal {

class TBranchIMTHelper {
public:
   template<typename FN> void Run(const FN &lambda) {
#ifdef R__USE_IMT
      if (!fGroup) { fGroup.reset(new tbb::task_group()); }
      fGroup->run( [=]() {
         auto nbytes = lambda();
         if (nbytes >= 0) {
            fBytes += nbytes;
         } else {
            ++fNerrors;
         }
      });
#else
      (void)lambda;
#endif
   }

   void Wait() {
#ifdef R__USE_IMT
      if (fGroup) fGroup->wait();
#endif
   }

   Long64_t GetNbytes() { return fBytes; }
   Long64_t GetNerrors() {  return fNerrors; }

private:
   std::atomic<Long64_t> fBytes{0};   // Total number of bytes written by this helper.
   std::atomic<Int_t>    fNerrors{0}; // Total error count of all tasks done by this helper.
#ifdef R__USE_IMT
   std::unique_ptr<tbb::task_group> fGroup;
#endif
};

} // Internal
} // ROOT

#endif<commit_msg>Remove direct usage of TBB in the tree in favour of TTaskGroup.<commit_after>// @(#)root/tree:$Id$
// Author: <NAME>, 2017

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TBranchIMTHelper
#define ROOT_TBranchIMTHelper

#include "Rtypes.h"

#ifdef R__USE_IMT
#include "ROOT/TTaskGroup.hxx"
#endif

/// A helper class for managing IMT work during TTree:Fill operations.
///
namespace ROOT {
namespace Internal {

class TBranchIMTHelper {

using TaskGroup_t = ROOT::Experimental::TTaskGroup;

public:
   template<typename FN> void Run(const FN &lambda) {
#ifdef R__USE_IMT
      if (!fGroup) { fGroup.reset(new TaskGroup_t()); }
      fGroup->Run( [=]() {
         auto nbytes = lambda();
         if (nbytes >= 0) {
            fBytes += nbytes;
         } else {
            ++fNerrors;
         }
      });
#else
      (void)lambda;
#endif
   }

   void Wait() {
#ifdef R__USE_IMT
      if (fGroup) fGroup->Wait();
#endif
   }

   Long64_t GetNbytes() { return fBytes; }
   Long64_t GetNerrors() {  return fNerrors; }

private:
   std::atomic<Long64_t> fBytes{0};   // Total number of bytes written by this helper.
   std::atomic<Int_t>    fNerrors{0}; // Total error count of all tasks done by this helper.
#ifdef R__USE_IMT
   std::unique_ptr<TaskGroup_t> fGroup;
#endif
};

} // Internal
} // ROOT

#endif
{'fraction_non_alphanumeric': 0.19459614831848232, 'fraction_numerical': 0.012072434607645875, 'mean_word_length': 2.2923368022705772, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2248490', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1024, 'n_words': 269}