1 #ifndef GUI_OBJUTILS___APP_JOB_DISPATCHER__HPP
2 #define GUI_OBJUTILS___APP_JOB_DISPATCHER__HPP
48 class IAppJobListener;
125 static void ReleaseInstance();
140 bool RegisterEngine(
const string& name,
IAppJobEngine& engine);
145 IEngineParams* params =
NULL);
151 bool auto_delete =
false,
152 IEngineParams* params =
NULL);
158 bool auto_delete =
false,
159 IEngineParams* params =
NULL);
166 void Mute(
bool bMute=
true);
168 void CancelJob(
TJobID job_id);
169 void SuspendJob(
TJobID job_id);
170 void ResumeJob(
TJobID job_id);
172 void CancelAllJobs();
177 bool DeleteJob(
TJobID job_id);
199 string GetStatusString(
TJobState job_state);
224 int report_period,
bool auto_delete);
237 : m_JobId(job_id), m_Progress(progress) {}
247 : m_Job(&job), m_NewState(new_state) {}
251 void x_AddJobRecord(SJobRecord& rec);
252 void x_RemoveJobRecord(SJobRecord& rec);
254 TJobID x_StartJob(
IAppJob& job,
const string& engine_name,
256 bool auto_delete, IEngineParams* params);
261 IAppJobEngine* x_GetRegisteredEngine(
const string& engine_name);
262 SJobRecord* x_GetJobRecord(TJobID job_id);
263 SJobRecord* x_GetJobRecord(
IAppJob& job);
268 void x_OnJobStateChanged(SJobRecord& rec, TJobState new_state);
270 void x_OnJobStateChangedNotify(SJobRecord& rec);
271 void x_OnJobProgressNotify(SJobRecord& rec);
273 bool x_PollEngines();
277 void x_FlushStateEventQueue();
281 bool x_IsCanceled(
int job_id)
const;
CAppJobEventTranslator Standard Listener that generates notification events.
IAppJobListener Interface for components that need to be notified about changes in Jobs.
CAppJobNotification Notification send by CAppJobEventTranslator.
CEvent - generic event implementation TODO TODO - Attachments.
IAppJobEngineListener - receives notifications about changes in job state.
#define EXCEPTION_VIRTUAL_BASE
Do not use virtual base classes in exception declaration at all, because in this case derived class s...
NCBI_EXCEPTION_DEFAULT(CAppJobException, CException)
CConstIRef< IAppJobError > GetError() const
returns non-null pointer only if job Failed
CConstIRef< IAppJobProgress > m_Progress
IAppJob::EJobState TJobState
TTimeToItem m_PollQueue
Job Index (by pointer)
SQueueItem(int job_id, bool progress)
multimap< time_t, SQueueItem > TTimeToItem
static CRef< CAppJobDispatcher > sm_Dispatcher
global dispatcher, this instance is used by default in most cases, however it is possible to create a...
CRef< CObject > GetResult() const
returns non-null pointer only if Completed or Running and has temporary results available
virtual ~IAppJobEngineListener()
IAppJob::EJobState TJobState
CGuard< CAppJobDispatcher > TDispatcherGuard
CEventHandler & m_TargetEventHandler
map< string, CIRef< IAppJobEngine > > TNameToEngine
map< IAppJob *, SJobRecord * > TPtrToRec
CConstIRef< IAppJobError > m_Error
TStateEventQueue m_StateEventQueue
priority queue for Dispatcher to poll on
SJobStateEvent(IAppJob &job, TJobState new_state)
bool m_AutoDelete
delete the record when job finishes
int m_ReportPeriod
if > 0, active progress reporting is required
DECLARE_CLASS_STATIC_MUTEX(sm_Mutex)
CWeakIRef< CEventHandler > m_TargetWeakPtr
CFastMutex m_EngineMutex
Engines registry mutex.
CIRef< CAppJobEventTranslator > m_Listener
if not null - "active" mode
EJobState
Job states (describe FSM)
bool m_ShutDownInProgress
Shutdown flag.
TPtrToRec m_PtrToRec
Job Registry (index by JobID)
IAppJob::EJobState TJobState
CConstIRef< IAppJobProgress > GetProgress() const
returns non-null pointer only if notification type is eProgress
CAppJobDispatcher::TJobID TJobID
bool ActiveProgress() const
IAppJob::EJobState TJobState
list< SJobStateEvent > TStateEventQueue
TJobState GetState() const
TNameToEngine m_NameToEngine
Engines Registry.
map< TJobID, SJobRecord * > TIDToRec
CConstIRef< IAppJobProgress > m_Progress
CAppJobDispatcher::TJobID TJobID
CMutex m_MainMutex
guards this instance of the Dispatcher
virtual void OnEngineJobStateChanged(IAppJob &job, TJobState new_state)=0
CAppJobDispatcher * m_Dispatcher
CFastMutex m_StateEventMutex
bm::bvector m_CancelVect
Canceled jobs vector.
@ eEngine_UnknownJob
the job is not registered in the Engine
@ eUnknownJob
Job record lost.
@ eEngine_InvalidParams
Invalid parameters provided to the Engine.
@ eEngineFailed
Engine failed to perforn an operation.
@ eEngine_IncompatibleJob
the Job is incompatible with the Engine
@ eEngineBusy
Engine is busy, caller needs to re-try the operation.
@ eInvalidOperation
Dispatcher - operation is invalid.
@ eEngine_InvalidOperation
Engine - operation is invalid.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define NCBI_GUIUTILS_EXPORT
#define NCBI_GUIOBJUTILS_EXPORT
Compressed bitset (entry point to bm.h)
SJobRecord describes a Job registered in Dispatcher.
SQueueItem - element of the Polling Queue.