CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
24 #include <boost/optional.hpp>
26 namespace catapult {
namespace cache {
33 template<
typename TCacheView>
55 template<
typename TCacheView>
64 explicit operator bool()
const {
100 template<
typename TCacheView>
128 template<
typename TCacheView>
138 std::shared_ptr<detail::CacheViewReadLockPair<TCacheView>>
m_pPair;
146 template<
typename TCacheView>
160 boost::optional<utils::SpinReaderWriterLock::ReaderLockGuard>
m_readLock;
167 template<
typename TCacheDelta>
201 template<
typename TCache>
233 auto delta =
m_cache.createDelta();
234 auto pPair = std::make_shared<detail::CacheViewReadLockPair<CacheDeltaType>>(std::move(delta), std::move(readLock));
243 auto delta =
m_cache.createDetachedDelta();
253 auto writeLock = pDeltaPair->ReadLock.promoteToWriter();
254 m_cache.commit(pDeltaPair->CacheView);
276 template<
typename TCache>
287 template<
typename... TArgs>
292 this->
cache().init(std::forward<TArgs>(args)...);
utils::SpinReaderWriterLock::ReaderLockGuard ReadLock
Read lock.
Definition: SynchronizedCache.h:47
Definition: SynchronizedCache.h:101
Decorator that synchronizes access to a cache and allows custom cache initialization.
Definition: SynchronizedCache.h:277
A cache view accessor.
Definition: SynchronizedCache.h:56
SynchronizedCache(TCache &&cache)
Creates a synchronized decorator around cache.
Definition: SynchronizedCache.h:211
const size_t & m_commitCounter
Definition: SynchronizedCache.h:192
TCacheView CacheView
Cache view.
Definition: SynchronizedCache.h:44
void commit()
Commits all pending changes to the underlying storage.
Definition: SynchronizedCache.h:248
typename BasicAccountStateCache ::CacheReadOnlyType CacheReadOnlyType
Definition: SynchronizedCache.h:207
bool m_isInitCalled
Definition: SynchronizedCache.h:297
TCache m_cache
Definition: SynchronizedCache.h:265
typename BasicAccountStateCache ::CacheDeltaType CacheDeltaType
Definition: SynchronizedCache.h:206
LockedCacheView< CacheViewType > createView() const
Returns a locked cache view based on this cache.
Definition: SynchronizedCache.h:218
size_t m_initialCommitCount
Definition: SynchronizedCache.h:191
boost::optional< utils::SpinReaderWriterLock::ReaderLockGuard > m_readLock
Definition: SynchronizedCache.h:160
LockedCacheView(TCacheView &&cacheView, utils::SpinReaderWriterLock::ReaderLockGuard &&readLock)
Creates a view around cacheView and readLock.
Definition: SynchronizedCache.h:104
TCacheView & operator*()
Gets a reference to the underlying cache view.
Definition: SynchronizedCache.h:85
LockedCacheView(LockedCacheView &&rhs)
Definition: SynchronizedCache.h:112
utils::SpinReaderWriterLock m_lock
Definition: SynchronizedCache.h:268
LockableCacheDelta(TCacheDelta &&cacheDelta, const size_t &commitCounter, utils::SpinReaderWriterLock &lock)
Definition: SynchronizedCache.h:172
const TCacheView * operator->() const
Gets a const pointer to the underlying cache view.
Definition: SynchronizedCache.h:69
TCacheView * m_pCacheView
Definition: SynchronizedCache.h:90
ReaderLockGuard acquireReader()
Blocks until a reader lock can be acquired.
Definition: SpinReaderWriterLock.h:153
OptionalLockedCacheDelta< TCacheDelta > tryLock()
Definition: SynchronizedCache.h:182
OptionalLockedCacheDelta(TCacheView &cacheView, utils::SpinReaderWriterLock::ReaderLockGuard &&readLock)
Creates a view around cacheView and pReadLock.
Definition: SynchronizedCache.h:154
utils::SpinReaderWriterLock::ReaderLockGuard m_readLock
Definition: SynchronizedCache.h:120
A cache-delta, read-lock pair.
Definition: SynchronizedCache.h:129
typename BasicAccountStateCache ::CacheViewType CacheViewType
Definition: SynchronizedCache.h:205
OptionalLockedCacheDelta()
Creates a empty view.
Definition: SynchronizedCache.h:150
utils::SpinReaderWriterLock & m_lock
Definition: SynchronizedCache.h:193
typename cache::AccountRestrictionCacheTypes::CacheReadOnlyType CacheReadOnlyType
Definition: AddressInteractionValidator.cpp:30
TCache & cache()
Gets a typed reference to the underlying cache.
Definition: SynchronizedCache.h:260
Decorator that synchronizes access to a cache.
Definition: SynchronizedCache.h:202
LockedCacheDelta(const std::shared_ptr< detail::CacheViewReadLockPair< TCacheView >> &pPair)
Creates a view around pPair.
Definition: SynchronizedCache.h:132
TCacheDelta m_cacheDelta
Definition: SynchronizedCache.h:190
typename BasicAccountStateCache ::CacheValueType CacheValueType
Definition: SynchronizedCache.h:204
size_t m_commitCounter
Definition: SynchronizedCache.h:266
#define CATAPULT_THROW_RUNTIME_ERROR(MESSAGE)
Macro used to throw a catapult runtime error.
Definition: exceptions.h:167
TCacheView * operator->()
Gets a pointer to the underlying cache view.
Definition: SynchronizedCache.h:80
A reader lock guard.
Definition: SpinReaderWriterLock.h:99
CacheViewReadLockPair(TCacheView &&cacheView, utils::SpinReaderWriterLock::ReaderLockGuard &&readLock)
Creates a pair around cacheView and readLock.
Definition: SynchronizedCache.h:37
std::shared_ptr< detail::CacheViewReadLockPair< TCacheView > > m_pPair
Definition: SynchronizedCache.h:138
TCacheView m_cacheView
Definition: SynchronizedCache.h:119
const TCacheView & operator*() const
Gets a const reference to the underlying cache view.
Definition: SynchronizedCache.h:74
std::weak_ptr< detail::CacheViewReadLockPair< CacheDeltaType > > m_pWeakDeltaPair
Definition: SynchronizedCache.h:267
Definition: AddressExtractionExtension.cpp:28
LockableCacheDelta< CacheDeltaType > createDetachedDelta() const
Definition: SynchronizedCache.h:241
LockedCacheDelta< CacheDeltaType > createDelta()
Definition: SynchronizedCache.h:225
Definition: SynchronizedCache.h:34
An optional cache-delta, read-lock pair.
Definition: SynchronizedCache.h:147
Definition: SpinReaderWriterLock.h:36
SynchronizedCacheWithInit(TCache &&cache)
Creates a synchronized decorator around cache.
Definition: SynchronizedCache.h:280
void init(TArgs &&... args)
Initializes the underlying cache with args.
Definition: SynchronizedCache.h:288
CacheViewAccessor(TCacheView *pCacheView)
Creates an accessor around pCacheView;.
Definition: SynchronizedCache.h:59
Definition: SynchronizedCache.h:168