this->
id== match_id;
87 return&*this->task == match_task;
125 const CTime& exec_time);
213 const CTime& exec_time,
241 typedefdeque< CRef<CScheduler_QueueEvent> >
TExecList;
281 const CTime& exec_time,
297event_info->
id= id;
298event_info->
task= task;
300event_info->
period= period;
337(*it)->OnNextExecutionTimeChange(
this);
369 boolis_begin_removed =
false;
374 if((*it)->IsMatch(task)) {
376is_begin_removed =
true;
386 if((*it)->IsMatch(task)) {
391 if(is_begin_removed) {
426(*series)[ind].id = (*it)->id;
427(*series)[ind].task = (*it)->task;
433series->resize(ind + 1);
434(*series)[ind].id = (*it)->id;
435(*series)[ind].task = (*it)->task;
519res_info.
id= event_info->
id;
520res_info.
task= event_info->
task;
551 if((*it)->IsMatch(series_id)) {
558 if(event_info.
IsNull()) {
565now + event_info->
period,
607 virtual void*
Main(
void);
627: m_Scheduler(scheduler),
672task_info.
task->Execute();
674 catch(exception& e) {
675 ERR_POST_X(1,
"Exception in scheduler task execution: "void Release()
Manually force the resource to be released.
Standalone thread to execute scheduled tasks - implementation.
CScheduler_ExecThread_Impl & operator=(const CScheduler_ExecThread_Impl &)
void Stop(void)
Stop executing the tasks, and finish the thread.
virtual ~CScheduler_ExecThread_Impl()
Destructor, to be called from CRef.
volatile bool m_Stopped
If the thread has been requested to stop.
virtual void * Main(void)
Main thread function.
CIRef< IScheduler > m_Scheduler
Scheduler controlled by the executor.
CSemaphore m_WaitTrigger
Semaphore for handling idle waiting.
CScheduler_ExecThread_Impl(const CScheduler_ExecThread_Impl &)
Prohibit copying and assignment.
CRef< CScheduler_ExecThread_Impl > m_SelfRef
Reference to self to avoid destruction earlier than needed.
CScheduler_ExecThread_Impl(IScheduler *scheduler)
Constructor.
virtual void OnNextExecutionTimeChange(IScheduler *)
Callback from the scheduler â about changes in the execution timeline.
CScheduler_ExecutionThread(IScheduler *scheduler)
Constructor.
CScheduler_ExecThread_Impl * m_Impl
Implementation of the thread.
virtual ~CScheduler_ExecutionThread()
Thread-safe implementation of IScheduler interface.
CScheduler_MT(void)
Constructor.
TExecList m_ExecutingTasks
List of executing tasks.
TSchedQueue m_ScheduledTasks
Queue of scheduled tasks.
CTime m_NextExecTime
Time of execution of nearest task.
virtual ~CScheduler_MT(void)
Destructor. To be called from CRef.
virtual TScheduler_SeriesID AddTask(IScheduler_Task *task, const CTime &exec_time)
Schedule task for one-time execution.
void x_SchedQueueChanged(CMutexGuard *guard)
Change next execution time when queue of scheduled tasks is changed.
TScheduler_SeriesID x_AddQueueTask(TScheduler_SeriesID id, IScheduler_Task *task, const CTime &exec_time, const CTimeSpan &period, CScheduler_QueueEvent::ERepeatPattern repeat_pattern, CMutexGuard *guard)
Schedule task execution.
CScheduler_MT(const CScheduler_MT &)
Prohibit copying and assigning.
CSyncQueue_multiset< CRef< CScheduler_QueueEvent >, PScheduler_QueueEvent_Compare > TSchedQueue
Type of queue for information about scheduled tasks.
CAtomicCounter m_IDCounter
Counter for generating task id.
CMutex m_MainMutex
Main mutex for protection of changes in scheduler.
virtual void RemoveTask(IScheduler_Task *task)
Remove task from scheduler queue.
virtual SScheduler_SeriesInfo GetNextTaskToExecute(const CTime &now)
Get information about next task that is ready to execute If there are no tasks to execute then return...
virtual TScheduler_SeriesID AddRepetitiveTask(IScheduler_Task *task, const CTime &start_time, const CTimeSpan &period, ERepeatPattern repeat_pattern)
Schedule task for repetitive execution.
vector< IScheduler_Listener * > TListenersList
Type of list of all scheduler listeners.
virtual void GetScheduledSeries(vector< SScheduler_SeriesInfo > *series) const
Get full scheduler series list.
virtual void RemoveSeries(TScheduler_SeriesID series_id)
Remove series from scheduler queue.
virtual void RemoveAllSeries(void)
Unschedule all series waiting in scheduler queue.
virtual CTime GetNextExecutionTime(void) const
Get next time point when scheduler will be ready to execute some task If there are already tasks to e...
TListenersList m_Listeners
List of all scheduler listeners.
CScheduler_MT & operator=(const CScheduler_MT &)
deque< CRef< CScheduler_QueueEvent > > TExecList
Type of list of information about currently executing tasks.
virtual void UnregisterListener(IScheduler_Listener *listener)
Remove scheduler listener.
void x_RemoveTaskImpl(T task)
Implementation of removing task from queue.
virtual bool HasTasksToExecute(const CTime &now) const
Check if there are tasks ready to execute.
virtual void RegisterListener(IScheduler_Listener *listener)
Add listener which will be notified about changing in time of availability of next scheduled task.
virtual bool IsEmpty(void) const
Check if there are tasks in scheduler queue (if it is not empty)
virtual void TaskExecuted(TScheduler_SeriesID series_id, const CTime &now)
Be aware that task was just finished its execution.
Class storing full information about scheduled event for task execution.
bool IsMatch(IScheduler_Task *match_task) const
Check if this event matches given task.
CTimeSpan period
Period of repetitive execution of the task.
bool IsMatch(bool dummy_val) const
Dummy function to support code templates and avoid duplication of code.
TScheduler_SeriesID id
Id of the series.
bool IsMatch(TScheduler_SeriesID match_id) const
Check if this event matches given series id.
ERepeatPattern
How to run repetitive tasks including not repeating at all.
@ eNoRepeat
Execute the task only once.
@ eWithDelay
Execute tasks in the specified period of time after the *END* of previous task's execution.
@ eWithRate
Execute tasks in the specified period of time after the *START* of previous task's execution.
CIRef< IScheduler_Task > task
Task itself.
ERepeatPattern repeat_pattern
Repeating pattern of the task.
CTime exec_time
Time when this event will be executed.
Adaptor class to use STL multiset<> in CSyncQueue.
void push_back(const typename TBaseType::value_type &elem)
TBaseType::iterator erase(typename TBaseType::iterator iter)
TBaseType::const_reference front() const
CTimeout â Timeout interval.
Interface to get notifications about selected changes in the scheduler timeline.
General interface for scheduled tasks.
Task scheduler interface.
ERepeatPattern
How to run repetitive tasks.
@ eWithDelay
Execute tasks in the specified period of time after the *END* of previous task's execution.
@ eWithRate
Execute tasks in the specified period of time after the *START* of previous task's execution.
static CIRef< IScheduler > Create(void)
Create a stock MT-safe scheduler.
const_iterator begin() const
const_iterator end() const
parent_type::iterator iterator
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
void Set(TValue new_value) THROWS_NONE
Set atomic counter value.
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
bool IsNull(void) const THROWS_NONE
Check if pointer is null â same effect as Empty().
#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".
@ fRunDetached
Run the thread detached (non-joinable)
CTime & SetCurrent(void)
Make the time current in the presently active time zone.
CTime & SetTimeT(const time_t t)
Set time using time_t time value.
@ eCurrent
Use current time. See also CCurrentTime.
Definition of all error codes used in util (xutil.lib).
Scheduler-related classes.
unsigned int TScheduler_SeriesID
Type of scheduled series identifier.
Multi-threading â mutexes; rw-locks; semaphore.
Class for comparing references to CSchedQueueTask by its execution time.
bool operator()(const CRef< CScheduler_QueueEvent > &left, const CRef< CScheduler_QueueEvent > &right) const
Information about scheduled series.
CIRef< IScheduler_Task > task
Smart-pointer to the task.
TScheduler_SeriesID id
Identifier of the series.
Definition of synchronized queue (CSyncQueue template) and templates related to it.
static const time_t kInfinityTimeT
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