24#ifndef MYSQL_SCHEDULER_SCHEDULED_TASK_H
25#define MYSQL_SCHEDULER_SCHEDULED_TASK_H
125 return m_schedule->is_enqueued_by_scheduler();
Shared state for one logical repeatable scheduler task.
Definition: scheduled_task.h:55
Repeatable_task_state & operator=(const Repeatable_task_state &)=delete
Repeatable_task_type m_repeatable_task
Repeatable task body shared by all scheduled task instances.
Definition: scheduled_task.h:80
bool execute(unsigned int thread_id)
Executes the repeatable task body for one phase dispatch.
Definition: scheduled_task.h:74
Repeatable_task_state(const Repeatable_task_state &)=delete
Repeatable_task_state(std::atomic< std::size_t > &scheduled_tasks_cnt, Repeatable_task_type &&repeatable_task)
Creates shared state for a logical repeatable task.
Definition: scheduled_task.cpp:30
std::atomic< std::size_t > & m_scheduled_tasks_cnt
Reference to the scheduler's logical task counter.
Definition: scheduled_task.h:78
~Repeatable_task_state()
Decrements the logical scheduled task count.
Definition: scheduled_task.cpp:36
std::function< bool(unsigned int)> Repeatable_task_type
Definition: scheduled_task.h:57
Represents task that is scheduled in the priority queue.
Definition: scheduled_task.h:87
Repeatable_task_state_ptr get_repeatable_task()
Gets the shared repeatable task state that owns task lifetime.
Definition: scheduled_task.h:130
Task_schedule_ptr m_schedule
Task schedule.
Definition: scheduled_task.h:152
Func_type m_task
Task function.
Definition: scheduled_task.h:148
Dispatch_reason get_dispatch_reason() const
Gets the dispatch reason for this task instance.
Definition: scheduled_task.h:134
std::function< Task_result(unsigned int)> Func_type
Definition: scheduled_task.h:88
void set_enqueued_by_scheduler()
Sets the repeatable task and marks as enqueued by scheduler.
Definition: scheduled_task.h:120
bool operator<(const Scheduled_task &arg) const
Returns task with a lower priority - operator needed for the priority queue.
Definition: scheduled_task.cpp:49
Task_id get_id() const
Gets the task ID.
Definition: scheduled_task.h:113
void set_dispatch_reason(Dispatch_reason dispatch_reason)
Sets the dispatch reason for this task instance.
Definition: scheduled_task.h:138
Scheduler_clock::Time_point_t get_task_delay() const
Gets the task delay time point.
Definition: scheduled_task.h:107
bool is_enqueued_by_scheduler()
Checks if enqueued by scheduler.
Definition: scheduled_task.h:124
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.
Definition: scheduled_task.cpp:38
Task_id m_task_id
Task identifier (local to scheduler)
Definition: scheduled_task.h:146
Repeatable_task_state_ptr m_repeatable_task
Shared repeatable task state carrying execution and logical lifetime.
Definition: scheduled_task.h:150
int m_phase
Current phase counter.
Definition: scheduled_task.h:154
bool is_phase_ready() const
Checks if the current phase is ready.
Definition: scheduled_task.h:117
Dispatch_reason m_dispatch_reason
Dispatch reason assigned when task is released to the worker pool.
Definition: scheduled_task.h:156
uint64_t Time_point_t
Definition: scheduler_clock.h:54
Main scheduling class.
Definition: scheduler.h:66
Represents the identifier of a task ingested by the scheduler,.
Definition: task_id.h:41
static my_thread_id thread_id
Definition: my_thr_init.cc:60
Definition: base_dependency_tracker.h:41
Dispatch_reason
Definition: dispatch_reason.h:29
Task_result
Acceptable task state after its execution.
Definition: task_result.h:32
std::shared_ptr< Task_schedule > Task_schedule_ptr
Definition: task_schedule.h:41
std::shared_ptr< Repeatable_task_state > Repeatable_task_state_ptr
Definition: scheduled_task.h:83