NCBI C++ ToolKit
|
Search Toolkit Book for CGraphCache
#include <gui/widgets/seq_graphic/graph_cache.hpp>
Public Member Functions | |
virtual | ~CGraphCache () |
void | Stop () |
CRef< TData > | GetCachedData (const string &data_key) |
Retrieves TData from in-memory cache. More... | |
CRef< TData > | GetData (const string &data_key) |
Retrieves TData from in-memory cache or if not found calls TData::Init to initialize new TData instance. More... | |
void | RemoveData (const string &data_key) |
Removes Data from in-memory cache. More... | |
void | SaveData (CRef< TData > data) |
Clones TData, puts it into Save Queue for asynchroneous storage operation. More... | |
void | EnableICache (bool value) |
![]() | |
CObject (void) | |
Constructor. More... | |
CObject (const CObject &src) | |
Copy constructor. More... | |
virtual | ~CObject (void) |
Destructor. More... | |
CObject & | operator= (const CObject &src) THROWS_NONE |
Assignment operator. More... | |
bool | CanBeDeleted (void) const THROWS_NONE |
Check if object can be deleted. More... | |
bool | IsAllocatedInPool (void) const THROWS_NONE |
Check if object is allocated in memory pool (not system heap) More... | |
bool | Referenced (void) const THROWS_NONE |
Check if object is referenced. More... | |
bool | ReferencedOnlyOnce (void) const THROWS_NONE |
Check if object is referenced only once. More... | |
void | AddReference (void) const |
Add reference to object. More... | |
void | RemoveReference (void) const |
Remove reference to object. More... | |
void | ReleaseReference (void) const |
Remove reference without deleting object. More... | |
virtual void | DoNotDeleteThisObject (void) |
Mark this object as not allocated in heap – do not delete this object. More... | |
virtual void | DoDeleteThisObject (void) |
Mark this object as allocated in heap – object can be deleted. More... | |
void * | operator new (size_t size) |
Define new operator for memory allocation. More... | |
void * | operator new[] (size_t size) |
Define new[] operator for 'array' memory allocation. More... | |
void | operator delete (void *ptr) |
Define delete operator for memory deallocation. More... | |
void | operator delete[] (void *ptr) |
Define delete[] operator for memory deallocation. More... | |
void * | operator new (size_t size, void *place) |
Define new operator. More... | |
void | operator delete (void *ptr, void *place) |
Define delete operator. More... | |
void * | operator new (size_t size, CObjectMemoryPool *place) |
Define new operator using memory pool. More... | |
void | operator delete (void *ptr, CObjectMemoryPool *place) |
Define delete operator. More... | |
virtual void | DebugDump (CDebugDumpContext ddc, unsigned int depth) const |
Define method for dumping debug information. More... | |
![]() | |
CDebugDumpable (void) | |
virtual | ~CDebugDumpable (void) |
void | DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const |
void | DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const |
void | DumpToConsole (void) const |
Static Public Member Functions | |
static CGraphCache & | GetInstance () |
![]() | |
static NCBI_XNCBI_EXPORT void | ThrowNullPointerException (void) |
Define method to throw null pointer exception. More... | |
static NCBI_XNCBI_EXPORT void | ThrowNullPointerException (const type_info &type) |
static EAllocFillMode | GetAllocFillMode (void) |
static void | SetAllocFillMode (EAllocFillMode mode) |
static void | SetAllocFillMode (const string &value) |
Set mode from configuration parameter value. More... | |
![]() | |
static void | EnableDebugDump (bool on) |
Private Types | |
using | TDataKey = string |
Private Member Functions | |
CGraphCache () | |
CGraphCache (const CGraphCache &)=delete | |
CGraphCache & | operator= (const CGraphCache &)=delete |
void | x_Run (CRef< CRequestContext > context) |
Private Attributes | |
mutex | m_Lock |
Saving Queue and Cache lock. More... | |
queue< CRef< TData > > | m_Queue |
Saving Queue for storage operations. More... | |
bool | m_HasICache = false |
Flag indicates if data should be saved into ICache. More... | |
map< TDataKey, CRef< TData > > | m_Cache |
in-memory data cache More... | |
TGraphCachePool | m_Storage |
ICache pool. More... | |
condition_variable | m_CV |
wake-up signal for save requests More... | |
thread | m_Thread |
background thread for save processing More... | |
atomic< bool > | m_StopRequested {false} |
flag to stop the backround thread More... | |
Friends | |
class | CSafeStatic_Allocator< CGraphCache > |
Additional Inherited Members | |
![]() | |
enum | EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern } |
Control filling of newly allocated memory. More... | |
typedef CObjectCounterLocker | TLockerType |
Default locker type for CRef. More... | |
typedef atomic< Uint8 > | TCounter |
Counter type is CAtomiCounter. More... | |
typedef Uint8 | TCount |
Alias for value type of counter. More... | |
![]() | |
static const TCount | eCounterBitsCanBeDeleted = 1 << 0 |
Define possible object states. More... | |
static const TCount | eCounterBitsInPlainHeap = 1 << 1 |
Heap signature was found. More... | |
static const TCount | eCounterBitsPlaceMask |
Mask for 'in heap' state flags. More... | |
static const int | eCounterStep = 1 << 2 |
Skip over the "in heap" bits. More... | |
static const TCount | eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2) |
Minimal value for valid objects (reference counter is zero) Must be a single bit value. More... | |
static const TCount | eCounterStateMask |
Valid object, and object in heap. More... | |
![]() | |
virtual void | DeleteThis (void) |
Virtual method "deleting" this object. More... | |
CGraphCache –.
in-memeory cache for graph data Provides concurrent access and asynchroneous storage operation for TData
TData is expected to provide: Init() - method to be called to initialize data Save() - method to serialize data
ICache storage is not used by default the caller needs to invoke EnableICache() to enable it
if ICache is enabled GraphCache start a backround thread (m_Thread) on first save request The consecutive save request sends a copy of data to m_Queue for asynchroneous Save.
Definition at line 93 of file graph_cache.hpp.
|
private |
Definition at line 232 of file graph_cache.hpp.
|
inlinevirtual |
Definition at line 103 of file graph_cache.hpp.
References ERR_POST, Error(), and CGraphCache< TData >::Stop().
|
inlineprivate |
Definition at line 196 of file graph_cache.hpp.
|
privatedelete |
|
inline |
Definition at line 192 of file graph_cache.hpp.
References CGraphCache< TData >::m_HasICache, and value.
Referenced by CSGAlignmentDS::EnablePileUpCache().
|
inline |
Retrieves TData from in-memory cache.
data_key | memory access key generated by TData |
Definition at line 124 of file graph_cache.hpp.
References CGraphCache< TData >::m_Cache, and CGraphCache< TData >::m_Lock.
Referenced by CSGAlignmentDS::IsGraphCached(), CVcfFeatureJob::x_Execute(), and CSGFeatureJob::x_ProcessCachedVcfTabix().
|
inline |
Retrieves TData from in-memory cache or if not found calls TData::Init to initialize new TData instance.
data_key | memory access key generated by TData |
Definition at line 140 of file graph_cache.hpp.
References CGraphCache< TData >::m_Cache, CGraphCache< TData >::m_HasICache, CGraphCache< TData >::m_Lock, CGraphCache< TData >::m_Storage, and Ref().
Referenced by CSGAlignmentDS::CanShowRange(), CSGAlignmentDS::GetGraphCost(), CSGAlignmentDS::IsRangeCached(), CSGAlignStatJob::x_Execute(), CSGSeqGraphJob::x_Execute(), CVcfFeatureJob::x_Execute(), and CSGFeatureJob::x_ProcessCachedBigBed().
|
inlinestatic |
Definition at line 97 of file graph_cache.hpp.
References CSafeStatic< T, Callbacks >::Get().
Referenced by CSGAlignmentDS::CanShowRange(), CSGAlignmentDS::ClearCache(), CSGAlignmentDS::EnablePileUpCache(), CVcfHistogram::EraseCachePerAnnotation(), CSGAlignmentDS::GetGraphCost(), CSGAlignmentDS::IsGraphCached(), CSGAlignmentDS::IsRangeCached(), CSGAlignStatJob::x_Execute(), CSGSeqGraphJob::x_Execute(), CVcfFeatureJob::x_Execute(), CWigGraph::x_FetchData(), CSGFeatureJob::x_ProcessCachedBigBed(), and CSGFeatureJob::x_ProcessCachedVcfTabix().
|
privatedelete |
|
inline |
Removes Data from in-memory cache.
data_key | memory access key generated by TData |
Definition at line 161 of file graph_cache.hpp.
References map_checker< Container >::end(), map_checker< Container >::erase(), map_checker< Container >::find(), CGraphCache< TData >::m_Cache, and CGraphCache< TData >::m_Lock.
Referenced by CSGAlignmentDS::ClearCache(), and CSGAlignStatJob::x_Execute().
|
inline |
Clones TData, puts it into Save Queue for asynchroneous storage operation.
data | Instance of TData |
Definition at line 173 of file graph_cache.hpp.
References CDiagContext::GetRequestContext(), CGraphCache< TData >::m_CV, CGraphCache< TData >::m_HasICache, CGraphCache< TData >::m_Lock, CGraphCache< TData >::m_Queue, CGraphCache< TData >::m_Thread, and CGraphCache< TData >::x_Run().
Referenced by CSGAlignStatJob::x_Execute(), CVcfFeatureJob::x_Execute(), and CWigGraph::x_FetchData().
|
inline |
Definition at line 111 of file graph_cache.hpp.
References CGraphCache< TData >::m_CV, CGraphCache< TData >::m_StopRequested, and CGraphCache< TData >::m_Thread.
Referenced by CGraphCache< TData >::~CGraphCache().
|
inlineprivate |
Definition at line 205 of file graph_cache.hpp.
References CGraphCache< TData >::m_CV, CGraphCache< TData >::m_Lock, CGraphCache< TData >::m_Queue, CGraphCache< TData >::m_StopRequested, CGraphCache< TData >::m_Storage, and CDiagContext::SetRequestContext().
Referenced by CGraphCache< TData >::SaveData().
|
friend |
Definition at line 196 of file graph_cache.hpp.
|
private |
in-memory data cache
Definition at line 233 of file graph_cache.hpp.
Referenced by CGraphCache< TData >::GetCachedData(), CGraphCache< TData >::GetData(), and CGraphCache< TData >::RemoveData().
|
private |
wake-up signal for save requests
Definition at line 237 of file graph_cache.hpp.
Referenced by CGraphCache< TData >::SaveData(), CGraphCache< TData >::Stop(), and CGraphCache< TData >::x_Run().
|
private |
Flag indicates if data should be saved into ICache.
Definition at line 230 of file graph_cache.hpp.
Referenced by CGraphCache< TData >::EnableICache(), CGraphCache< TData >::GetData(), and CGraphCache< TData >::SaveData().
|
private |
Saving Queue and Cache lock.
Definition at line 226 of file graph_cache.hpp.
Referenced by CGraphCache< TData >::GetCachedData(), CGraphCache< TData >::GetData(), CGraphCache< TData >::RemoveData(), CGraphCache< TData >::SaveData(), and CGraphCache< TData >::x_Run().
|
private |
Saving Queue for storage operations.
Definition at line 228 of file graph_cache.hpp.
Referenced by CGraphCache< TData >::SaveData(), and CGraphCache< TData >::x_Run().
|
private |
flag to stop the backround thread
Definition at line 239 of file graph_cache.hpp.
Referenced by CGraphCache< TData >::Stop(), and CGraphCache< TData >::x_Run().
|
private |
ICache pool.
Definition at line 235 of file graph_cache.hpp.
Referenced by CGraphCache< TData >::GetData(), and CGraphCache< TData >::x_Run().
|
private |
background thread for save processing
Definition at line 238 of file graph_cache.hpp.
Referenced by CGraphCache< TData >::SaveData(), and CGraphCache< TData >::Stop().