From feb84b9ea1868ad10051287c2d05c88eeb8082d4 Mon Sep 17 00:00:00 2001
From: Enrico Guiraud <enrico.guiraud@cern.ch>
Date: Fri, 31 Aug 2018 16:40:48 +0200
Subject: [PATCH] [DF][NFC] Rename Internal::RDF::{T => R}SlotStack

---
 tree/dataframe/inc/ROOT/RDFNodes.hxx    |  8 ++++----
 tree/dataframe/src/RDFNodes.cxx         | 20 ++++++++++----------
 tree/dataframe/test/dataframe_nodes.cxx | 16 ++++++++--------
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/tree/dataframe/inc/ROOT/RDFNodes.hxx b/tree/dataframe/inc/ROOT/RDFNodes.hxx
index ba5574ded3d..314def90b7b 100644
--- a/tree/dataframe/inc/ROOT/RDFNodes.hxx
+++ b/tree/dataframe/inc/ROOT/RDFNodes.hxx
@@ -30,7 +30,7 @@
 #include <functional>
 #include <limits>
 #include <map>
-#include <numeric> // std::accumulate (FillReport), std::iota (TSlotStack)
+#include <numeric> // std::accumulate (FillReport), std::iota (RSlotStack)
 #include <stack>
 #include <string>
 #include <thread>
@@ -56,7 +56,7 @@ class GraphCreatorHelper;
 // indexed by thread ids.
 // WARNING: this class does not work as a regular stack. The size is
 // fixed at construction time and no blocking is foreseen.
-class TSlotStack {
+class RSlotStack {
 private:
    unsigned int &GetCount();
    unsigned int &GetIndex();
@@ -65,8 +65,8 @@ private:
    ROOT::TRWSpinLock fRWLock;
 
 public:
-   TSlotStack() = delete;
-   TSlotStack(unsigned int size) : fCursor(size), fBuf(size) { std::iota(fBuf.begin(), fBuf.end(), 0U); }
+   RSlotStack() = delete;
+   RSlotStack(unsigned int size) : fCursor(size), fBuf(size) { std::iota(fBuf.begin(), fBuf.end(), 0U); }
    void ReturnSlot(unsigned int slotNumber);
    unsigned int GetSlot();
    std::map<std::thread::id, unsigned int> fCountMap;
diff --git a/tree/dataframe/src/RDFNodes.cxx b/tree/dataframe/src/RDFNodes.cxx
index 60ac9b673bf..3609df154b2 100644
--- a/tree/dataframe/src/RDFNodes.cxx
+++ b/tree/dataframe/src/RDFNodes.cxx
@@ -328,7 +328,7 @@ void RJittedFilter::AddFilterName(std::vector<std::string> &filters)
    fConcreteFilter->AddFilterName(filters);
 }
 
-unsigned int &TSlotStack::GetCount()
+unsigned int &RSlotStack::GetCount()
 {
    const auto tid = std::this_thread::get_id();
    {
@@ -343,7 +343,7 @@ unsigned int &TSlotStack::GetCount()
       return (fCountMap[tid] = 0U);
    }
 }
-unsigned int &TSlotStack::GetIndex()
+unsigned int &RSlotStack::GetIndex()
 {
    const auto tid = std::this_thread::get_id();
 
@@ -359,24 +359,24 @@ unsigned int &TSlotStack::GetIndex()
    }
 }
 
-void TSlotStack::ReturnSlot(unsigned int slotNumber)
+void RSlotStack::ReturnSlot(unsigned int slotNumber)
 {
    auto &index = GetIndex();
    auto &count = GetCount();
-   R__ASSERT(count > 0U && "TSlotStack has a reference count relative to an index which will become negative.");
+   R__ASSERT(count > 0U && "RSlotStack has a reference count relative to an index which will become negative.");
    count--;
    if (0U == count) {
       index = std::numeric_limits<unsigned int>::max();
       ROOT::TRWSpinLockWriteGuard guard(fRWLock);
       fBuf[fCursor++] = slotNumber;
       R__ASSERT(fCursor <= fBuf.size() &&
-                "TSlotStack assumes that at most a fixed number of values can be present in the "
+                "RSlotStack assumes that at most a fixed number of values can be present in the "
                 "stack. fCursor is greater than the size of the internal buffer. This violates "
                 "such assumption.");
    }
 }
 
-unsigned int TSlotStack::GetSlot()
+unsigned int RSlotStack::GetSlot()
 {
    auto &index = GetIndex();
    auto &count = GetCount();
@@ -385,7 +385,7 @@ unsigned int TSlotStack::GetSlot()
       return index;
    ROOT::TRWSpinLockWriteGuard guard(fRWLock);
    R__ASSERT(fCursor > 0 &&
-             "TSlotStack assumes that a value can be always obtained. In this case fCursor is <=0 and this "
+             "RSlotStack assumes that a value can be always obtained. In this case fCursor is <=0 and this "
              "violates such assumption.");
    index = fBuf[--fCursor];
    return index;
@@ -416,7 +416,7 @@ RLoopManager::RLoopManager(std::unique_ptr<RDataSource> ds, const ColumnNames_t
 void RLoopManager::RunEmptySourceMT()
 {
 #ifdef R__USE_IMT
-   TSlotStack slotStack(fNSlots);
+   RSlotStack slotStack(fNSlots);
    // Working with an empty tree.
    // Evenly partition the entries according to fNSlots. Produce around 2 tasks per slot.
    const auto nEntriesPerSlot = fNEmptyEntries / (fNSlots * 2);
@@ -463,7 +463,7 @@ void RLoopManager::RunEmptySource()
 void RLoopManager::RunTreeProcessorMT()
 {
 #ifdef R__USE_IMT
-   TSlotStack slotStack(fNSlots);
+   RSlotStack slotStack(fNSlots);
    auto tp = std::make_unique<ROOT::TTreeProcessorMT>(*fTree);
 
    tp->Process([this, &slotStack](TTreeReader &r) -> void {
@@ -523,7 +523,7 @@ void RLoopManager::RunDataSourceMT()
 {
 #ifdef R__USE_IMT
    R__ASSERT(fDataSource != nullptr);
-   TSlotStack slotStack(fNSlots);
+   RSlotStack slotStack(fNSlots);
    ROOT::TThreadExecutor pool;
 
    // Each task works on a subrange of entries
diff --git a/tree/dataframe/test/dataframe_nodes.cxx b/tree/dataframe/test/dataframe_nodes.cxx
index ea29c4965d3..7937985d997 100644
--- a/tree/dataframe/test/dataframe_nodes.cxx
+++ b/tree/dataframe/test/dataframe_nodes.cxx
@@ -7,20 +7,20 @@
 
 #include "gtest/gtest.h"
 
-TEST(RDataFrameNodes, TSlotStackCheckSameThreadSameSlot)
+TEST(RDataFrameNodes, RSlotStackCheckSameThreadSameSlot)
 {
    unsigned int n(7);
-   ROOT::Internal::RDF::TSlotStack s(n);
+   ROOT::Internal::RDF::RSlotStack s(n);
    EXPECT_EQ(s.GetSlot(), s.GetSlot());
 }
 
 #ifndef NDEBUG
 
-TEST(RDataFrameNodes, TSlotStackGetOneTooMuch)
+TEST(RDataFrameNodes, RSlotStackGetOneTooMuch)
 {
    auto theTest = []() {
       unsigned int n(2);
-      ROOT::Internal::RDF::TSlotStack s(n);
+      ROOT::Internal::RDF::RSlotStack s(n);
 
       std::vector<std::thread> ts;
 
@@ -32,17 +32,17 @@ TEST(RDataFrameNodes, TSlotStackGetOneTooMuch)
          t.join();
    };
 
-   EXPECT_DEATH(theTest(), "TSlotStack assumes that a value can be always obtained.");
+   EXPECT_DEATH(theTest(), "RSlotStack assumes that a value can be always obtained.");
 }
 
-TEST(RDataFrameNodes, TSlotStackPutBackTooMany)
+TEST(RDataFrameNodes, RSlotStackPutBackTooMany)
 {
    auto theTest = []() {
-      ROOT::Internal::RDF::TSlotStack s(1);
+      ROOT::Internal::RDF::RSlotStack s(1);
       s.ReturnSlot(0);
    };
 
-   EXPECT_DEATH(theTest(), "TSlotStack has a reference count relative to an index which will become negative");
+   EXPECT_DEATH(theTest(), "RSlotStack has a reference count relative to an index which will become negative");
 }
 
 #endif
-- 
GitLab