Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
novadaq::CacheManager Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-03-03/NovaDAQUtilities/cxx/include/CacheManager.h"

Public Member Functions

void registerCache (Cache *cache)
 
void removeCache (Cache *cache)
 
void flushCaches ()
 

Static Public Member Functions

static CacheManagergetInstance ()
 

Private Member Functions

 CacheManager ()
 
 CacheManager (CacheManager const &)
 
void operator= (CacheManager const &)
 

Private Attributes

std::vector< Cache * > _registry
 
boost::mutex _registryMutex
 

Detailed Description

A singleton class to manage flushing of caches.

Author
Kurt Biery
Version
Revision
1.1.34.1
Date
2019/09/27 00:07:20

Definition at line 17 of file CacheManager.h.

Constructor & Destructor Documentation

novadaq::CacheManager::CacheManager ( )
inlineexplicitprivate

Default constructor.

Definition at line 34 of file CacheManager.h.

References operator=().

34 {};
novadaq::CacheManager::CacheManager ( CacheManager const &  )
private

Member Function Documentation

void novadaq::CacheManager::flushCaches ( )

Flushes the caches that have been registered.

Definition at line 41 of file CacheManager.cpp.

References _registry, _registryMutex, and compare_h5_caf::idx.

Referenced by CacheTests::testEnvVarCacheBasic().

41  {
42  boost::mutex::scoped_lock lock(_registryMutex);
43  for (uint32_t idx = 0; idx < _registry.size(); ++idx) {
44  _registry[idx]->flush();
45  }
46 }
std::vector< Cache * > _registry
Definition: CacheManager.h:43
boost::mutex _registryMutex
Definition: CacheManager.h:48
CacheManager & novadaq::CacheManager::getInstance ( )
static

Returns the single instance of the CacheManager.

Returns
CacheManager instance.

Definition at line 10 of file CacheManager.cpp.

Referenced by novadaq::EnvVarCache::EnvVarCache(), and CacheTests::testEnvVarCacheBasic().

10  {
11  static CacheManager singletonInstance;
12  return singletonInstance;
13 }
void novadaq::CacheManager::operator= ( CacheManager const &  )
private

Referenced by CacheManager().

void novadaq::CacheManager::registerCache ( Cache cache)

Registers the specified cache with the CacheManager. Registered caches will be flushed when the CacheManager receives a flush request.

Parameters
cachea pointer to the cache that should be registered.

Definition at line 22 of file CacheManager.cpp.

References _registry, and _registryMutex.

Referenced by novadaq::EnvVarCache::EnvVarCache().

22  {
23  boost::mutex::scoped_lock lock(_registryMutex);
24  _registry.push_back(cache);
25 }
std::vector< Cache * > _registry
Definition: CacheManager.h:43
boost::mutex _registryMutex
Definition: CacheManager.h:48
void novadaq::CacheManager::removeCache ( Cache cache)

Removes the specified cache from the CacheManager.

Parameters
cachea pointer to the cache that should be removed.

Definition at line 32 of file CacheManager.cpp.

References _registry, and _registryMutex.

32  {
33  boost::mutex::scoped_lock lock(_registryMutex);
34  _registry.erase(remove(_registry.begin(), _registry.end(), cache),
35  _registry.end());
36 }
std::vector< Cache * > _registry
Definition: CacheManager.h:43
boost::mutex _registryMutex
Definition: CacheManager.h:48

Member Data Documentation

std::vector<Cache*> novadaq::CacheManager::_registry
private

The list of registered caches.

Definition at line 43 of file CacheManager.h.

Referenced by flushCaches(), registerCache(), and removeCache().

boost::mutex novadaq::CacheManager::_registryMutex
private

A mutex to protect against concurrent use of the registry.

Definition at line 48 of file CacheManager.h.

Referenced by flushCaches(), registerCache(), and removeCache().


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