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

Shared state for one logical repeatable scheduler task. More...

#include <scheduled_task.h>

Public Types

using Repeatable_task_type = std::function< bool(unsigned int)>
 

Public Member Functions

 Repeatable_task_state (std::atomic< std::size_t > &scheduled_tasks_cnt, Repeatable_task_type &&repeatable_task)
 Creates shared state for a logical repeatable task. More...
 
 ~Repeatable_task_state ()
 Decrements the logical scheduled task count. More...
 
 Repeatable_task_state (const Repeatable_task_state &)=delete
 
Repeatable_task_stateoperator= (const Repeatable_task_state &)=delete
 
bool execute (unsigned int thread_id)
 Executes the repeatable task body for one phase dispatch. More...
 

Private Attributes

std::atomic< std::size_t > & m_scheduled_tasks_cnt
 Reference to the scheduler's logical task counter. More...
 
Repeatable_task_type m_repeatable_task
 Repeatable task body shared by all scheduled task instances. More...
 

Detailed Description

Shared state for one logical repeatable scheduler task.

This object is shared by all scheduled representations of the same logical task, including the currently queued phase, the task handed off to a worker, and any follow-up phase enqueued by the scheduler.

It combines:

  • the repeatable task callable, executed by each task phase
  • the logical task lifetime accounting for m_scheduled_tasks_cnt

The scheduler increments m_scheduled_tasks_cnt once when the logical task is created. The counter is decremented in this object's destructor, which means the decrement happens only after the last queued or running owner of the logical task releases its shared reference.

Member Typedef Documentation

◆ Repeatable_task_type

using mysql::scheduler::Repeatable_task_state::Repeatable_task_type = std::function<bool(unsigned int)>

Constructor & Destructor Documentation

◆ Repeatable_task_state() [1/2]

mysql::scheduler::Repeatable_task_state::Repeatable_task_state ( std::atomic< std::size_t > &  scheduled_tasks_cnt,
Repeatable_task_type &&  repeatable_task 
)

Creates shared state for a logical repeatable task.

Parameters
scheduled_tasks_cntReference to the scheduler task counter.
repeatable_taskRepeatable task callable shared across phases.

◆ ~Repeatable_task_state()

mysql::scheduler::Repeatable_task_state::~Repeatable_task_state ( )

Decrements the logical scheduled task count.

◆ Repeatable_task_state() [2/2]

mysql::scheduler::Repeatable_task_state::Repeatable_task_state ( const Repeatable_task_state )
delete

Member Function Documentation

◆ execute()

bool mysql::scheduler::Repeatable_task_state::execute ( unsigned int  thread_id)
inline

Executes the repeatable task body for one phase dispatch.

Parameters
thread_idWorker or scheduler thread identifier.
Returns
True if task execution reported an error, false otherwise.

◆ operator=()

Repeatable_task_state & mysql::scheduler::Repeatable_task_state::operator= ( const Repeatable_task_state )
delete

Member Data Documentation

◆ m_repeatable_task

Repeatable_task_type mysql::scheduler::Repeatable_task_state::m_repeatable_task
private

Repeatable task body shared by all scheduled task instances.

◆ m_scheduled_tasks_cnt

std::atomic<std::size_t>& mysql::scheduler::Repeatable_task_state::m_scheduled_tasks_cnt
private

Reference to the scheduler's logical task counter.


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