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

Search Toolkit Book for CAppJobDispatcher

CAppJobDispatcher. More...

#include <gui/utils/app_job_dispatcher.hpp>

+ Inheritance diagram for CAppJobDispatcher:
+ Collaboration diagram for CAppJobDispatcher:

Classes

struct  SJobRecord
 SJobRecord describes a Job registered in Dispatcher. More...
 
struct  SJobStateEvent
 
struct  SQueueItem
 SQueueItem - element of the Polling Queue. More...
 

Public Types

enum  EConsts { eInvalidJobID = -1 }
 
typedef IAppJob::EJobState TJobState
 
typedef int TJobID
 
typedef CGuard< CAppJobDispatcherTDispatcherGuard
 
- 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 Types inherited from IAppJobEngineListener
typedef IAppJob::EJobState TJobState
 

Public Member Functions

 CAppJobDispatcher ()
 Release the singleton. More...
 
virtual ~CAppJobDispatcher ()
 
void ShutDown ()
 Terminates all jobs and releases Engines. More...
 
bool IdleCallback ()
 this function shall be called in the the application idle function. More...
 
bool RegisterEngine (const string &name, IAppJobEngine &engine)
 Registers a new Engine, returns true if successful. More...
 
TJobID StartJob (IAppJob &job, const string &engine_name, IEngineParams *params=NULL)
 Starts a Job on the specified engine in "passive mode" - no notifications or progress reports will be sent. More...
 
TJobID StartJob (IAppJob &job, const string &engine_name, CEventHandler &listener, int report_period=-1, bool auto_delete=false, IEngineParams *params=NULL)
 Starts a Job on the specified engine; the provided listener will receive notification events when the Job's state changes. More...
 
TJobID StartJob (IAppJob &job, const string &engine_name, CAppJobEventTranslator &listener, int report_period=-1, bool auto_delete=false, IEngineParams *params=NULL)
 Starts a Job on the specified engine, Dispatcher will call methods of the provide listener when the Job's state changes. More...
 
void RunSync (IAppJob &job, TJobID &jobId, CEventHandler &listener)
 Runs jon synchronously sending job notifications synchronously Returns when job is finished. More...
 
void Mute (bool bMute=true)
 Mute all notifications. More...
 
void CancelJob (TJobID job_id)
 
void SuspendJob (TJobID job_id)
 
void ResumeJob (TJobID job_id)
 
void CancelAllJobs ()
 Request to cancel all jobs (func returns without waiting) More...
 
bool DeleteJob (TJobID job_id)
 when a Job is deleted the listener is not notified More...
 
TJobState GetJobState (TJobID job_id)
 All Get() functions return values stored in the Registy not the actual. More...
 
CConstIRef< IAppJobProgressGetJobProgress (TJobID job_id)
 
CRef< CObjectGetJobResult (TJobID job_id)
 
CConstIRef< IAppJobErrorGetJobError (TJobID job_id)
 
void Lock () const
 
void Unlock () const
 
IAppJobEngineListener
virtual void OnEngineJobStateChanged (IAppJob &job, TJobState new_state)
 IAppJobEngineListener. 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
 
- Public Member Functions inherited from IAppJobEngineListener
virtual ~IAppJobEngineListener ()
 

Static Public Member Functions

static CAppJobDispatcherGetInstance ()
 
static void ReleaseInstance ()
 get the Singleton Dispatcher More...
 
static string StateToStr (TJobState state)
 
static bool IsTerminal (TJobState state)
 
static string GetStatusString (TJobState job_state)
 Debugging method for status strings. 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 Types

typedef map< string, CIRef< IAppJobEngine > > TNameToEngine
 
typedef map< TJobID, SJobRecord * > TIDToRec
 
typedef map< IAppJob *, SJobRecord * > TPtrToRec
 
typedef multimap< time_t, SQueueItemTTimeToItem
 
typedef list< SJobStateEventTStateEventQueue
 

Protected Member Functions

void x_AddJobRecord (SJobRecord &rec)
 
void x_RemoveJobRecord (SJobRecord &rec)
 
TJobID x_StartJob (IAppJob &job, const string &engine_name, CAppJobEventTranslator *listener, int report_period, bool auto_delete, IEngineParams *params)
 
void x_OnJobStarted (IAppJob &job, IAppJobEngine &, CAppJobEventTranslator *listener, int report_period, bool)
 handles state transition More...
 
IAppJobEnginex_GetRegisteredEngine (const string &engine_name)
 Helper functions these functions rely on external synchronization and do not throw / catch exception. More...
 
SJobRecordx_GetJobRecord (TJobID job_id)
 
SJobRecordx_GetJobRecord (IAppJob &job)
 
void x_OnJobStateChangedNotify (SJobRecord &rec)
 
void x_OnJobProgressNotify (SJobRecord &rec)
 
bool x_PollEngines ()
 
void x_FlushStateEventQueue ()
 
void x_VerifyProgressNotNull (CAppJobDispatcher::SJobRecord &rec)
 
bool x_IsCanceled (int job_id) const
 
 DECLARE_CLASS_STATIC_MUTEX (sm_Mutex)
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Static Protected Member Functions

static void x_OnJobStateChanged (SJobRecord &rec, TJobState new_state)
 Update job record, throws an exception if new state change is incorrect. More...
 

Protected Attributes

CMutex m_MainMutex
 guards this instance of the Dispatcher More...
 
TNameToEngine m_NameToEngine
 Engines Registry. More...
 
CFastMutex m_EngineMutex
 Engines registry mutex. More...
 
int m_LastJobID
 
TIDToRec m_JobRecs
 
TPtrToRec m_PtrToRec
 Job Registry (index by JobID) More...
 
TTimeToItem m_PollQueue
 Job Index (by pointer) More...
 
TStateEventQueue m_StateEventQueue
 priority queue for Dispatcher to poll on More...
 
CFastMutex m_StateEventMutex
 
bool m_Mute
 
bm::bvector m_CancelVect
 Canceled jobs vector. More...
 
bool m_ShutDownInProgress
 Shutdown flag. More...
 

Static Protected Attributes

static CRef< CAppJobDispatchersm_Dispatcher
 global dispatcher, this instance is used by default in most cases, however it is possible to create another instance if needed More...
 

Friends

struct SJobRecord
 
struct SQueueItem
 
class CAppJobEventTranslator
 

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

Detailed Description

CAppJobDispatcher.

Definition at line 109 of file app_job_dispatcher.hpp.


The documentation for this class was generated from the following files:
Modified on Thu May 23 12:27:21 2024 by modify_doxy.py rev. 669887