NCBI C++ ToolKit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CSeqFetchQueue Class Reference

Search Toolkit Book for CSeqFetchQueue

#include <gui/objutils/seqfetch_queue.hpp>

+ Inheritance diagram for CSeqFetchQueue:
+ Collaboration diagram for CSeqFetchQueue:

Public Types

enum  ERetrievalFlags {
  fRetrieveSequence = 0x01 , fRetrieveCoreFeatures = 0x02 , fRetrieveFeatures = 0x04 , fRetrieveAll = fRetrieveSequence | fRetrieveFeatures ,
  fRetrieveRecursive = 0x08 , fRetrieveProducts = 0x10 , fDefaults = 0x0
}
 
typedef int TRetrievalFlags
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 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...
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (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...
 
- Public Member Functions inherited from CDebugDumpable
 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 CSeqFetchQueueGetInstance ()
 static interface to access singleton More...
 
- Static Public Member Functions inherited from CObject
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 Public Member Functions inherited from CDebugDumpable
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...
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Private Member Functions

 CSeqFetchQueue (const CSeqFetchQueue &)
 
CSeqFetchQueueoperator= (const CSeqFetchQueue &)
 
- Private Member Functions inherited from CStdPoolOfThreads
 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 TThreadNewThread (TThread::ERunMode mode)
 Create a new thread. More...
 
- Private Member Functions inherited from CPoolOfThreads< CRef< CStdRequest > >
 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...
 
- Private Attributes inherited from CPoolOfThreads< CRef< CStdRequest > >
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< intm_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 Public Attributes inherited from CObject
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...
 
- Private Types inherited from CStdPoolOfThreads
enum  EKillFlags { fKill_Wait = 0x1 , fKill_Reopen = 0x2 }
 
typedef CPoolOfThreads< CRef< CStdRequest > > TParent
 
typedef int TKillFlags
 binary OR of EKillFlags More...
 
- Private Types inherited from CPoolOfThreads< CRef< CStdRequest > >
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
 

Detailed Description

Definition at line 49 of file seqfetch_queue.hpp.

Member Typedef Documentation

◆ TRetrievalFlags

Definition at line 79 of file seqfetch_queue.hpp.

Member Enumeration Documentation

◆ ERetrievalFlags

Enumerator
fRetrieveSequence 

retrieve the sequence associated with the ID

fRetrieveCoreFeatures 

retrieve the "core" features this includes genes, mRNAs, and CDSs only

fRetrieveFeatures 

retrieve all features not in external annotations

fRetrieveAll 
fRetrieveRecursive 

should we enqueue all items recursively? levels below the requested level are retrieved with a lower priority to favor interactive tasks that need immediate attention

fRetrieveProducts 

should we enqueue product retrievals as well? this implies retrieval of mRNA and CDS features

fDefaults 

default just calls GetBioseqHandle()

Definition at line 53 of file seqfetch_queue.hpp.

Constructor & Destructor Documentation

◆ CSeqFetchQueue() [1/2]

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().

◆ CSeqFetchQueue() [2/2]

CSeqFetchQueue::CSeqFetchQueue ( const CSeqFetchQueue )
private

Member Function Documentation

◆ Add() [1/7]

void CSeqFetchQueue::Add ( const objects::CSeq_id &  id,
const TSeqRange range,
TRetrievalFlags  flags = fDefaults 
)

◆ Add() [2/7]

void CSeqFetchQueue::Add ( const objects::CSeq_id &  id,
TRetrievalFlags  flags = fDefaults 
)

Enqueue a single ID for retrieval.

Referenced by Add(), and CResolveRequest::Process().

◆ Add() [3/7]

void CSeqFetchQueue::Add ( const vector< objects::CSeq_id_Handle > &  ids,
TRetrievalFlags  flags = fDefaults 
)

Enqueue a set of IDs for retrieval.

◆ Add() [4/7]

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().

◆ Add() [5/7]

void CSeqFetchQueue::Add ( objects::CSeq_id_Handle  id,
const TSeqRange range,
TRetrievalFlags  flags = fDefaults 
)

◆ Add() [6/7]

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().

◆ Add() [7/7]

void CSeqFetchQueue::Add ( objects::CSeq_id_Handle  idh,
const TSeqRange range,
TRetrievalFlags  flags,
int  priority 
)
protected

internal version of add all of the other APIs feed into this one

◆ Clear()

void CSeqFetchQueue::Clear ( void  )

◆ Finish()

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().

◆ GetInstance()

CSeqFetchQueue & CSeqFetchQueue::GetInstance ( void  )
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().

◆ IsEmpty()

bool CSeqFetchQueue::IsEmpty ( void  ) const

◆ IsFull()

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.

◆ operator=()

CSeqFetchQueue& CSeqFetchQueue::operator= ( const CSeqFetchQueue )
private

Friends And Related Function Documentation

◆ CResolveRequest

friend class CResolveRequest
friend

Definition at line 123 of file seqfetch_queue.hpp.

Member Data Documentation

◆ m_IsShuttingDown

bool CSeqFetchQueue::m_IsShuttingDown
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.

Referenced by Add(), Clear(), and Finish().

◆ m_Scope

CRef<objects::CScope> CSeqFetchQueue::m_Scope
private

Definition at line 132 of file seqfetch_queue.hpp.


The documentation for this class was generated from the following files:
Modified on Sat Dec 09 04:45:58 2023 by modify_doxy.py rev. 669887