MySQL 26.7.0
Source Code Documentation
mysql::scheduler::Scheduled_task Class Reference

Represents task that is scheduled in the priority queue. More...

#include <scheduled_task.h>

Public Member Functions

 Scheduled_task (const Task_id &id, Func_type &&task, const Repeatable_task_state_ptr &repeatable_task, const Task_schedule_ptr &schedule, unsigned int phase_id)
 Constructor. More...
 
bool operator< (const Scheduled_task &arg) const
 Returns task with a lower priority - operator needed for the priority queue. More...
 
Scheduler_clock::Time_point_t get_task_delay () const
 Gets the task delay time point. More...
 
Task_id get_id () const
 Gets the task ID. More...
 
bool is_phase_ready () const
 Checks if the current phase is ready. More...
 
void set_enqueued_by_scheduler ()
 Sets the repeatable task and marks as enqueued by scheduler. More...
 
bool is_enqueued_by_scheduler ()
 Checks if enqueued by scheduler. More...
 
Repeatable_task_state_ptr get_repeatable_task ()
 Gets the shared repeatable task state that owns task lifetime. More...
 
Dispatch_reason get_dispatch_reason () const
 Gets the dispatch reason for this task instance. More...
 
void set_dispatch_reason (Dispatch_reason dispatch_reason)
 Sets the dispatch reason for this task instance. More...
 

Protected Attributes

Task_id m_task_id
 Task identifier (local to scheduler) More...
 
Func_type m_task
 Task function. More...
 
Repeatable_task_state_ptr m_repeatable_task
 Shared repeatable task state carrying execution and logical lifetime. More...
 
Task_schedule_ptr m_schedule
 Task schedule. More...
 
int m_phase {0}
 Current phase counter. More...
 
Dispatch_reason m_dispatch_reason {Dispatch_reason::normal}
 Dispatch reason assigned when task is released to the worker pool. More...
 

Private Types

using Func_type = std::function< Task_result(unsigned int)>
 

Friends

class Scheduler
 

Detailed Description

Represents task that is scheduled in the priority queue.

Member Typedef Documentation

◆ Func_type

using mysql::scheduler::Scheduled_task::Func_type = std::function<Task_result(unsigned int)>
private

Constructor & Destructor Documentation

◆ Scheduled_task()

mysql::scheduler::Scheduled_task::Scheduled_task ( const Task_id id,
Scheduled_task::Func_type &&  task,
const Repeatable_task_state_ptr repeatable_task,
const Task_schedule_ptr schedule,
unsigned int  phase_id 
)

Constructor.

Parameters
idTask ID
taskFunction to execute
repeatable_taskShared repeatable task state
scheduleRight reference to task schedule pointer
phase_idCurrent phase sequence number

Member Function Documentation

◆ get_dispatch_reason()

Dispatch_reason mysql::scheduler::Scheduled_task::get_dispatch_reason ( ) const
inline

Gets the dispatch reason for this task instance.

Returns
Dispatch reason assigned by the scheduler.

◆ get_id()

Task_id mysql::scheduler::Scheduled_task::get_id ( ) const
inline

Gets the task ID.

Returns
The task ID.

◆ get_repeatable_task()

Repeatable_task_state_ptr mysql::scheduler::Scheduled_task::get_repeatable_task ( )
inline

Gets the shared repeatable task state that owns task lifetime.

Returns
The shared repeatable task state pointer.

◆ get_task_delay()

Scheduler_clock::Time_point_t mysql::scheduler::Scheduled_task::get_task_delay ( ) const
inline

Gets the task delay time point.

Returns
The time point for the task delay.

◆ is_enqueued_by_scheduler()

bool mysql::scheduler::Scheduled_task::is_enqueued_by_scheduler ( )
inline

Checks if enqueued by scheduler.

Returns
true if enqueued by scheduler, false otherwise.

◆ is_phase_ready()

bool mysql::scheduler::Scheduled_task::is_phase_ready ( ) const
inline

Checks if the current phase is ready.

Returns
true if phase is ready, false otherwise.

◆ operator<()

bool mysql::scheduler::Scheduled_task::operator< ( const Scheduled_task arg) const

Returns task with a lower priority - operator needed for the priority queue.

◆ set_dispatch_reason()

void mysql::scheduler::Scheduled_task::set_dispatch_reason ( Dispatch_reason  dispatch_reason)
inline

Sets the dispatch reason for this task instance.

Parameters
dispatch_reasonReason assigned by the scheduler.

◆ set_enqueued_by_scheduler()

void mysql::scheduler::Scheduled_task::set_enqueued_by_scheduler ( )
inline

Sets the repeatable task and marks as enqueued by scheduler.

Friends And Related Function Documentation

◆ Scheduler

friend class Scheduler
friend

Member Data Documentation

◆ m_dispatch_reason

Dispatch_reason mysql::scheduler::Scheduled_task::m_dispatch_reason {Dispatch_reason::normal}
protected

Dispatch reason assigned when task is released to the worker pool.

◆ m_phase

int mysql::scheduler::Scheduled_task::m_phase {0}
protected

Current phase counter.

◆ m_repeatable_task

Repeatable_task_state_ptr mysql::scheduler::Scheduled_task::m_repeatable_task
protected

Shared repeatable task state carrying execution and logical lifetime.

◆ m_schedule

Task_schedule_ptr mysql::scheduler::Scheduled_task::m_schedule
protected

Task schedule.

◆ m_task

Func_type mysql::scheduler::Scheduled_task::m_task
protected

Task function.

◆ m_task_id

Task_id mysql::scheduler::Scheduled_task::m_task_id
protected

Task identifier (local to scheduler)


The documentation for this class was generated from the following files: