NCBI C++ ToolKit
|
Search Toolkit Book for CSeqFetchQueue
#include <gui/objutils/seqfetch_queue.hpp>
Public Types | |
enum | ERetrievalFlags { fRetrieveSequence = 0x01 , fRetrieveCoreFeatures = 0x02 , fRetrieveFeatures = 0x04 , fRetrieveAll = fRetrieveSequence | fRetrieveFeatures , fRetrieveRecursive = 0x08 , fRetrieveProducts = 0x10 , fDefaults = 0x0 } |
typedef int | TRetrievalFlags |
![]() | |
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... | |
Public Member Functions | |
CSeqFetchQueue (objects::CScope &scope, int threads=4, int max_queue_size=100000) | |
CSeqFetchQueue implementation details. More... | |
void | Add (const objects::CSeq_id &id, TRetrievalFlags flags=fDefaults) |
Enqueue a single ID for retrieval. More... | |
void | Add (const objects::CSeq_id &id, const TSeqRange &range, TRetrievalFlags flags=fDefaults) |
void | Add (objects::CSeq_id_Handle id, TRetrievalFlags flags=fDefaults) |
Enqueue a single ID for retrieval. More... | |
void | Add (objects::CSeq_id_Handle id, const TSeqRange &range, TRetrievalFlags flags=fDefaults) |
void | Add (const vector< objects::CSeq_id_Handle > &ids, TRetrievalFlags flags=fDefaults) |
Enqueue a set of IDs for retrieval. More... | |
void | Add (const vector< TGi > &ids, TRetrievalFlags flags=fDefaults) |
Enqueue a set of gis for retrieval. More... | |
bool | IsFull () const |
Ask if the queue is full or empty. More... | |
bool | IsEmpty () const |
void | Clear () |
Clear all items from the queue. More... | |
void | Finish () |
Finish processing of all items in the queue. More... | |
![]() | |
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 CSeqFetchQueue & | GetInstance () |
static interface to access singleton More... | |
![]() | |
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) |
Protected Member Functions | |
void | Add (objects::CSeq_id_Handle idh, const TSeqRange &range, TRetrievalFlags flags, int priority) |
internal version of add all of the other APIs feed into this one More... | |
![]() | |
virtual void | DeleteThis (void) |
Virtual method "deleting" this object. More... | |
Private Member Functions | |
CSeqFetchQueue (const CSeqFetchQueue &) | |
CSeqFetchQueue & | operator= (const CSeqFetchQueue &) |
![]() | |
CStdPoolOfThreads (unsigned int max_threads, unsigned int queue_size, unsigned int spawn_threshold=1, unsigned int max_urgent_threads=kMax_UInt, const string &thread_name=kEmptyStr) | |
Constructor. More... | |
virtual | ~CStdPoolOfThreads () |
virtual void | KillAllThreads (TKillFlags flags) |
Causes all threads in the pool to exit cleanly after finishing all pending requests, optionally waiting for them to die. More... | |
virtual void | KillAllThreads (bool wait) |
Causes all threads in the pool to exit cleanly after finishing all pending requests, optionally waiting for them to die. More... | |
virtual void | Register (TThread &thread) |
Register a thread. More... | |
virtual void | UnRegister (TThread &thread) |
Unregister a thread. More... | |
virtual TThread * | NewThread (TThread::ERunMode mode) |
Create a new thread. More... | |
![]() | |
CPoolOfThreads (unsigned int max_threads, unsigned int queue_size, unsigned int spawn_threshold=1, unsigned int max_urgent_threads=kMax_UInt, const string &thread_name=kEmptyStr) | |
Constructor. More... | |
virtual | ~CPoolOfThreads (void) |
Destructor. More... | |
void | Spawn (unsigned int num_threads) |
Start processing threads. More... | |
TItemHandle | AcceptRequest (const CRef< CStdRequest > &request, TUserPriority priority=0, unsigned int timeout_sec=0, unsigned int timeout_nsec=0) |
Put a request in the queue with a given priority. More... | |
TItemHandle | AcceptUrgentRequest (const CRef< CStdRequest > &request, unsigned int timeout_sec=0, unsigned int timeout_nsec=0) |
Puts a request in the queue with the highest priority It will run a new thread even if the maximum of allowed threads has been already reached. More... | |
void | WaitForRoom (unsigned int timeout_sec=kMax_UInt, unsigned int timeout_nsec=0) |
Wait for the room in the queue up to timeout_sec + timeout_nsec/1E9 seconds. More... | |
bool | IsFull (void) const |
Check if the queue is full. More... | |
bool | IsEmpty (void) const |
Check if the queue is empty. More... | |
bool | HasImmediateRoom (bool urgent=false) const |
Check whether a new request could be immediately processed. More... | |
void | SetUserPriority (TItemHandle handle, TUserPriority priority) |
Adjust a pending request's priority. More... | |
void | Withdraw (TItemHandle handle) |
Withdraw a pending request from consideration. More... | |
size_t | GetQueueSize (void) const |
Get the number of requests in the queue. More... | |
virtual void | Register (TThread &thread) |
Register a thread. More... | |
virtual void | UnRegister (TThread &) |
Unregister a thread. More... | |
Private Attributes | |
CRef< objects::CScope > | m_Scope |
bool | m_IsShuttingDown |
flag: set to true when the class is shutting down this blocks all further acceptances More... | |
![]() | |
CAtomicCounter_WithAutoInit | m_MaxThreads |
The maximum number of threads the pool can hold. More... | |
CAtomicCounter_WithAutoInit | m_MaxUrgentThreads |
The maximum number of urgent threads running simultaneously. More... | |
int | m_Threshold |
for delta More... | |
CAtomicCounter_WithAutoInit | m_ThreadCount |
The current number of threads in the pool. More... | |
CAtomicCounter_WithAutoInit | m_UrgentThreadCount |
The current number of urgent threads running now. More... | |
atomic< int > | m_Delta |
The difference between the number of unfinished requests and the total number of threads in the pool. More... | |
CMutex | m_Mutex |
The guard for m_MaxThreads, m_MaxUrgentThreads, and m_Delta. More... | |
TQueue | m_Queue |
The request queue. More... | |
bool | m_QueuingForbidden |
const string | m_ThreadName |
Friends | |
class | CResolveRequest |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
enum | EKillFlags { fKill_Wait = 0x1 , fKill_Reopen = 0x2 } |
typedef CPoolOfThreads< CRef< CStdRequest > > | TParent |
typedef int | TKillFlags |
binary OR of EKillFlags More... | |
![]() | |
typedef CThreadInPool< CRef< CStdRequest > > | TThread |
typedef TThread::ERunMode | ERunMode |
typedef CBlockingQueue< CRef< CStdRequest > > | TQueue |
typedef TQueue::TUserPriority | TUserPriority |
typedef TQueue::TItemHandle | TItemHandle |
typedef CAtomicCounter::TValue | TACValue |
Definition at line 49 of file seqfetch_queue.hpp.
typedef int CSeqFetchQueue::TRetrievalFlags |
Definition at line 79 of file seqfetch_queue.hpp.
Definition at line 53 of file seqfetch_queue.hpp.
CSeqFetchQueue::CSeqFetchQueue | ( | objects::CScope & | scope, |
int | threads = 4 , |
||
int | max_queue_size = 100000 |
||
) |
CSeqFetchQueue implementation details.
Definition at line 248 of file seqfetch_queue.cpp.
Referenced by GetInstance().
|
private |
void CSeqFetchQueue::Add | ( | const objects::CSeq_id & | id, |
const TSeqRange & | range, | ||
TRetrievalFlags | flags = fDefaults |
||
) |
void CSeqFetchQueue::Add | ( | const objects::CSeq_id & | id, |
TRetrievalFlags | flags = fDefaults |
||
) |
Enqueue a single ID for retrieval.
Referenced by Add(), and CResolveRequest::Process().
void CSeqFetchQueue::Add | ( | const vector< objects::CSeq_id_Handle > & | ids, |
TRetrievalFlags | flags = fDefaults |
||
) |
Enqueue a set of IDs for retrieval.
void CSeqFetchQueue::Add | ( | const vector< TGi > & | ids, |
TRetrievalFlags | flags = fDefaults |
||
) |
Enqueue a set of gis for retrieval.
Definition at line 380 of file seqfetch_queue.cpp.
References Add(), flags, CSeq_id_Handle::GetGiHandle(), COpenRange< TSeqPos >::GetWhole(), ITERATE, m_IsShuttingDown, and compile_time_bits::range().
void CSeqFetchQueue::Add | ( | objects::CSeq_id_Handle | id, |
const TSeqRange & | range, | ||
TRetrievalFlags | flags = fDefaults |
||
) |
void CSeqFetchQueue::Add | ( | objects::CSeq_id_Handle | id, |
TRetrievalFlags | flags = fDefaults |
||
) |
Enqueue a single ID for retrieval.
enqueue an ID for retrieval
Definition at line 351 of file seqfetch_queue.cpp.
References Add(), flags, COpenRange< TSeqPos >::GetWhole(), m_IsShuttingDown, and compile_time_bits::range().
|
protected |
internal version of add all of the other APIs feed into this one
void CSeqFetchQueue::Clear | ( | void | ) |
Clear all items from the queue.
Definition at line 287 of file seqfetch_queue.cpp.
References Finish(), CBlockingQueue< TRequest >::GetHandle(), IsEmpty(), m_IsShuttingDown, and CPoolOfThreads< CRef< CStdRequest > >::m_Queue.
void CSeqFetchQueue::Finish | ( | void | ) |
Finish processing of all items in the queue.
Definition at line 297 of file seqfetch_queue.cpp.
References CPoolOfThreads< CRef< CStdRequest > >::AcceptRequest(), IsEmpty(), CStdPoolOfThreads::KillAllThreads(), and m_IsShuttingDown.
Referenced by Clear().
|
static |
static interface to access singleton
Definition at line 257 of file seqfetch_queue.cpp.
References CScope::AddDefaults(), CSeqFetchQueue(), DEFINE_STATIC_MUTEX, CObjectManager::GetInstance(), om, and CRef< C, Locker >::Reset().
bool CSeqFetchQueue::IsEmpty | ( | void | ) | const |
Definition at line 281 of file seqfetch_queue.cpp.
References CBlockingQueue< TRequest >::IsEmpty(), and CPoolOfThreads< CRef< CStdRequest > >::m_Queue.
bool CSeqFetchQueue::IsFull | ( | void | ) | const |
Ask if the queue is full or empty.
Definition at line 275 of file seqfetch_queue.cpp.
References CBlockingQueue< TRequest >::IsFull(), and CPoolOfThreads< CRef< CStdRequest > >::m_Queue.
|
private |
|
friend |
Definition at line 123 of file seqfetch_queue.hpp.
|
private |
flag: set to true when the class is shutting down this blocks all further acceptances
Definition at line 136 of file seqfetch_queue.hpp.
|
private |
Definition at line 132 of file seqfetch_queue.hpp.