*
Main(
void)
65: m_WakeSignal(0, 10000000),
83 LOG_POST(
Info<<
"CSchedulerEngine::ShutDown(): completed");
111s +=
" does not implement IWaitPeriod interface";
118 for(
const auto&
i:
m_Jobs) {
119 if(
i.m_Job == &job) {
121s +=
" has been already started on this Engine";
130 m_Jobs.push_back(record);
142 if(
i.m_Job == &job) {
152 static const char* kMsg =
"CSchedulerEngine::SuspendJob()\ 153 - operation is not supported";
160 static const char* kMsg =
"CSchedulerEngine::ResumeJob()\ 161 - operation is not supported";
170 for(
const auto&
i:
m_Jobs) {
171 if(
i.m_Job == &job)
return i.m_JobState;
180 LOG_POST(
Info<<
"Scheduler Engine - working thread started");
182 unsigned intwait = 10000;
195 LOG_POST(
Info<<
"Scheduler Engine - working thread finished");
204wait =
min(wait,
i.m_NextExec.DiffSecond(now));
206 return(
unsigned long)
max((
Int8)0, wait);
215 if(
i.m_NextExec <= now) {
230 NCBI_CATCH(
"CSchedulerEngine::x_RunJobs()");
233list<CJobRecord>::iterator it =
m_Jobs.begin();
234 for(;it !=
m_Jobs.end(); ++it) {
235 if(it->m_Job == toRun)
239 if(it ==
m_Jobs.end())
return;
242it->m_JobState =
state;
IAppJobListener Interface for components that need to be notified about changes in Jobs.
virtual void * Main(void)
Derived (user-created) class must provide a real thread function.
CSchedulerEngineThread(CSchedulerEngine *engine)
CSchedulerEngine * m_Engine
CSchedulerEngine CSchedulerEngine is an engine that can be used with CAppJobDispatcher.
virtual void ShutDown()
stop any background threads and free resources associated with the Engine
unsigned long x_GetWaitPeriod()
CSchedulerEngine()
CSchedulerEngine.
virtual bool IsActive()
Returns true if Engine supports "active" model i.e.
virtual void ResumeJob(IAppJob &)
virtual void SetListener(IAppJobEngineListener *listener)
For "active" mode set a Listener that will be notified when the state of a Job changes.
list< CJobRecord > m_Jobs
void StartJob(IAppJob &job, IEngineParams *)
If Engine cannot start the Job and exception shall be thrown.
virtual void SuspendJob(IAppJob &)
friend class CSchedulerEngineThread
virtual void RequestCancel()
asyncronous request all jobs to Cancel
virtual void CancelJob(IAppJob &job)
Cancel job in the engine If job is not running yet - just remove from the pending queue otherwise use...
CAtomicCounter_WithAutoInit m_StopRequested
virtual ~CSchedulerEngine()
IAppJobEngineListener * m_Listener
void x_WorkOnThread()
performs job execution on a separate scheduling thread
CRef< CThread > m_WorkerThread
virtual TJobState GetJobState(IAppJob &job) const
IAppJobEngineListener - receives notifications about changes in job state.
void Set(TValue new_value) THROWS_NONE
Set atomic counter value.
TValue Get(void) const THROWS_NONE
Get atomic counter value.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_CATCH(message)
Catch CExceptions as well This macro is deprecated - use *_X or *_XX variant instead of it.
void Info(CExceptionArgs_Base &args)
virtual void RequestCancel()=0
RequestCancel() is called to notify the Job that it shall exit Run() function ASAP.
EJobState
Job states (describe FSM)
virtual string GetDescr() const =0
Returns a human readable description of the Job (optional)
virtual EJobState Run()=0
Function that does all the useful work, called by the Engine.
virtual void OnEngineJobStateChanged(IAppJob &job, TJobState new_state)=0
void Reset(void)
Reset reference object.
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
bool Run(TRunMode flags=fRunDefault)
Run the thread.
bool TryWait(unsigned int timeout_sec=0, unsigned int timeout_nsec=0)
Timed wait.
void Post(unsigned int count=1)
Increment the semaphore by "count".
void Join(void **exit_data=0)
Wait for the thread termination.
@ fRunNice
Run thread with low priority (MS-Win only)
@ eCurrent
Use current time. See also CCurrentTime.
record that holds infromation about a job
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4