From 04ecf22675e328c34559e5daff4161f879ff369c Mon Sep 17 00:00:00 2001
From: Enrico Guiraud <enrico.guiraud@cern.ch>
Date: Tue, 29 May 2018 17:11:19 +0200
Subject: [PATCH] [TREEPROCMT][NFC] Clarify usage of stack of entries in
 TTreeView

---
 tree/treeplayer/inc/ROOT/TTreeProcessorMT.hxx | 5 +++--
 tree/treeplayer/src/TTreeProcessorMT.cxx      | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tree/treeplayer/inc/ROOT/TTreeProcessorMT.hxx b/tree/treeplayer/inc/ROOT/TTreeProcessorMT.hxx
index 595532547cf..934700f2dad 100644
--- a/tree/treeplayer/inc/ROOT/TTreeProcessorMT.hxx
+++ b/tree/treeplayer/inc/ROOT/TTreeProcessorMT.hxx
@@ -274,6 +274,7 @@ namespace ROOT {
                reader->SetEntriesRange(start, end);
             }
 
+            // we need to return the entry list too, as it needs to be in scope as long as the reader is
             return std::make_pair(std::move(reader), std::move(elist));
          }
 
@@ -293,11 +294,11 @@ namespace ROOT {
 
          //////////////////////////////////////////////////////////////////////////
          /// Push a new loaded entry to the stack.
-         void PushLoadedEntry(Long64_t entry) { fLoadedEntries.push_back(entry); }
+         void PushTaskFirstEntry(Long64_t entry) { fLoadedEntries.push_back(entry); }
 
          //////////////////////////////////////////////////////////////////////////
          /// Restore the tree of the previous loaded entry, if any.
-         void RestoreLoadedEntry()
+         void PopTaskFirstEntry()
          {
             fLoadedEntries.pop_back();
             if (fLoadedEntries.size() > 0) {
diff --git a/tree/treeplayer/src/TTreeProcessorMT.cxx b/tree/treeplayer/src/TTreeProcessorMT.cxx
index 9bcb0d9d826..5d3cdf86614 100644
--- a/tree/treeplayer/src/TTreeProcessorMT.cxx
+++ b/tree/treeplayer/src/TTreeProcessorMT.cxx
@@ -111,14 +111,14 @@ void TTreeProcessorMT::Process(std::function<void(TTreeReader &)> func)
 
    auto mapFunction = [this, &func](const ROOT::Internal::TreeViewCluster &c) {
       // This task will operate with the tree that contains startEntry
-      treeView->PushLoadedEntry(c.startEntry);
+      treeView->PushTaskFirstEntry(c.startEntry);
 
       auto readerAndEntryList = treeView->GetTreeReader(c.startEntry, c.endEntry);
       auto &reader = std::get<0>(readerAndEntryList);
       func(*reader);
 
       // In case of task interleaving, we need to load here the tree of the parent task
-      treeView->RestoreLoadedEntry();
+      treeView->PopTaskFirstEntry();
    };
 
    // Assume number of threads has been initialized via ROOT::EnableImplicitMT
-- 
GitLab