CacheManager.cpp
Go to the documentation of this file.
1 #include <NovaDAQUtilities/CacheManager.h>
2 
3 namespace novadaq {
4 
5 /**
6  * Returns the single instance of the CacheManager.
7  *
8  * @returns CacheManager instance.
9  */
11  static CacheManager singletonInstance;
12  return singletonInstance;
13 }
14 
15 /**
16  * Registers the specified cache with the CacheManager. Registered
17  * caches will be flushed when the CacheManager receives a flush
18  * request.
19  *
20  * @param cache a pointer to the cache that should be registered.
21  */
23  boost::mutex::scoped_lock lock(_registryMutex);
24  _registry.push_back(cache);
25 }
26 
27 /**
28  * Removes the specified cache from the CacheManager.
29  *
30  * @param cache a pointer to the cache that should be removed.
31  */
33  boost::mutex::scoped_lock lock(_registryMutex);
34  _registry.erase(remove(_registry.begin(), _registry.end(), cache),
35  _registry.end());
36 }
37 
38 /**
39  * Flushes the caches that have been registered.
40  */
42  boost::mutex::scoped_lock lock(_registryMutex);
43  for (uint32_t idx = 0; idx < _registry.size(); ++idx) {
44  _registry[idx]->flush();
45  }
46 }
47 
48 } // end of namespace novadaq
void removeCache(Cache *cache)
static CacheManager & getInstance()
std::vector< Cache * > _registry
Definition: CacheManager.h:43
boost::mutex _registryMutex
Definition: CacheManager.h:48
void registerCache(Cache *cache)