@@ -721,15 +721,25 @@ struct DSRunRAII {
721
721
};
722
722
} // namespace
723
723
724
+ struct ROOT ::Internal::RDF::RDSRangeRAII {
725
+ ROOT::Detail::RDF::RLoopManager &fLM ;
726
+ unsigned int fSlot ;
727
+ RDSRangeRAII (ROOT::Detail::RDF::RLoopManager &lm, unsigned int slot, ULong64_t firstEntry) : fLM (lm), fSlot (slot)
728
+ {
729
+ fLM .InitNodeSlots (nullptr , fSlot );
730
+ fLM .GetDataSource ()->InitSlot (fSlot , firstEntry);
731
+ }
732
+ ~RDSRangeRAII () { fLM .GetDataSource ()->FinalizeSlot (fSlot ); }
733
+ };
734
+
724
735
// / Run event loop over data accessed through a DataSource, in sequence.
725
736
void RLoopManager::RunDataSource ()
726
737
{
727
738
assert (fDataSource != nullptr );
728
739
DSRunRAII _{*fDataSource };
729
740
auto ranges = fDataSource ->GetEntryRanges ();
730
741
while (!ranges.empty () && fNStopsReceived < fNChildren ) {
731
- InitNodeSlots (nullptr , 0u );
732
- fDataSource ->InitSlot (0u , 0ull );
742
+ RDSRangeRAII __{*this , 0u , 0ull };
733
743
RCallCleanUpTask cleanup (*this );
734
744
try {
735
745
for (const auto &range : ranges) {
@@ -746,7 +756,6 @@ void RLoopManager::RunDataSource()
746
756
std::cerr << " RDataFrame::Run: event loop was interrupted\n " ;
747
757
throw ;
748
758
}
749
- fDataSource ->FinalizeSlot (0u );
750
759
ranges = fDataSource ->GetEntryRanges ();
751
760
}
752
761
}
@@ -763,9 +772,8 @@ void RLoopManager::RunDataSourceMT()
763
772
auto runOnRange = [this , &slotStack](const std::pair<ULong64_t, ULong64_t> &range) {
764
773
ROOT::Internal::RSlotStackRAII slotRAII (slotStack);
765
774
const auto slot = slotRAII.fSlot ;
766
- InitNodeSlots ( nullptr , slot) ;
775
+ RDSRangeRAII _{* this , slot, range. first } ;
767
776
RCallCleanUpTask cleanup (*this , slot);
768
- fDataSource ->InitSlot (slot, range.first );
769
777
const auto start = range.first ;
770
778
const auto end = range.second ;
771
779
R__LOG_DEBUG (0 , RDFLogChannel ()) << LogRangeProcessing ({fDataSource ->GetLabel (), start, end, slot});
@@ -779,7 +787,6 @@ void RLoopManager::RunDataSourceMT()
779
787
std::cerr << " RDataFrame::Run: event loop was interrupted\n " ;
780
788
throw ;
781
789
}
782
- fDataSource ->FinalizeSlot (slot);
783
790
};
784
791
785
792
DSRunRAII _{*fDataSource };
0 commit comments