Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Internal::RDF::RStringCache Class Reference

A Thread-safe cache for strings.

This is used to generically store strings that are created in the computation graph machinery, for example when adding a new node.

Definition at line 285 of file Utils.hxx.

Public Member Functions

auto Insert (const std::string &string) -> decltype(fStrings)::const_iterator
 Inserts the input string in the cache and returns an iterator to the cached string.
 

Private Attributes

std::shared_mutex fMutex {}
 
std::unordered_set< std::string > fStrings {}
 

#include <ROOT/RDF/Utils.hxx>

Member Function Documentation

◆ Insert()

auto ROOT::Internal::RDF::RStringCache::Insert ( const std::string &  string) -> decltype(fStrings)::const_iterator

Inserts the input string in the cache and returns an iterator to the cached string.

The function implements the following strategy for thread-safety:

  1. Take a shared lock and early return if the string is already in the cache.
  2. Release the shared lock and take an exclusive lock.
  3. Check again if another thread filled the cache meanwhile. If so, return the cached value.
  4. Insert the new value in the cache and return.

Definition at line 445 of file RDFUtils.cxx.

Member Data Documentation

◆ fMutex

std::shared_mutex ROOT::Internal::RDF::RStringCache::fMutex {}
private

Definition at line 287 of file Utils.hxx.

◆ fStrings

std::unordered_set<std::string> ROOT::Internal::RDF::RStringCache::fStrings {}
private

Definition at line 286 of file Utils.hxx.

Libraries for ROOT::Internal::RDF::RStringCache:

The documentation for this class was generated from the following files: