MySQL 8.4.2
Source Code Documentation
ddl::Loader::Task_queue Class Reference

Unbounded task queue. More...

Public Member Functions

 Task_queue (const Context &ctx, bool sync) noexcept
 Constructor. More...
 
 ~Task_queue () noexcept
 Destructor. More...
 
void enqueue (const Task &task) noexcept
 Enqueue a task to execute. More...
 
dberr_t execute ()
 Dequeue and execute a task. More...
 
void thread_create_failed () noexcept
 Note that we failed to create the configured number of threads. More...
 
bool validate () const noexcept
 
void signal () noexcept
 Wakeup the other threads e.g., on error. More...
 

Private Types

using Tasks = std::deque< Task, ut::allocator< Task > >
 

Private Member Functions

dberr_t mt_execute ()
 Execute function when there is more than one thread. More...
 
dberr_t st_execute ()
 Execute function when there is a single thread. More...
 

Private Attributes

const Contextm_ctx
 DDL context. More...
 
bool m_sync {}
 true if synchronous execution model. More...
 
Tasks m_tasks {}
 The task queue. More...
 
ib_mutex_t m_mutex
 Mutex protecting m_tasks access. More...
 
os_event_t m_consumer_event {}
 Task queue consumer event. More...
 
size_t m_n_threads {}
 Number of threads (including foreground thread). More...
 
size_t m_n_idle {}
 Number of threads idle. More...
 
size_t m_n_tasks_executed {}
 Number of tasks executed. More...
 
size_t m_n_tasks_submitted {}
 Number of tasks submitted. More...
 

Detailed Description

Unbounded task queue.

Member Typedef Documentation

◆ Tasks

using ddl::Loader::Task_queue::Tasks = std::deque<Task, ut::allocator<Task> >
private

Constructor & Destructor Documentation

◆ Task_queue()

ddl::Loader::Task_queue::Task_queue ( const Context ctx,
bool  sync 
)
explicitnoexcept

Constructor.

Parameters
[in]ctxDDL context.
[in]syncTrue for synchronous execution.

◆ ~Task_queue()

ddl::Loader::Task_queue::~Task_queue ( )
noexcept

Destructor.

Member Function Documentation

◆ enqueue()

void ddl::Loader::Task_queue::enqueue ( const Task task)
inlinenoexcept

Enqueue a task to execute.

Parameters
[in]taskTask to queue.

◆ execute()

dberr_t ddl::Loader::Task_queue::execute ( )
inline

Dequeue and execute a task.

Returns
DB_SUCCESS or error code.

◆ mt_execute()

dberr_t ddl::Loader::Task_queue::mt_execute ( )
inlineprivate

Execute function when there is more than one thread.

The general idea is as follows:

  1. Some initial tasks are added before threads come here to execute tasks.
  2. While executing, a task can generate more tasks. That is the only way a task can be added.

[1] & [2] implies that when all threads are idle, all tasks are completed and no more tasks can be added.

We exit here when all running threads are idle.

◆ signal()

void ddl::Loader::Task_queue::signal ( )
inlinenoexcept

Wakeup the other threads e.g., on error.

◆ st_execute()

dberr_t ddl::Loader::Task_queue::st_execute ( )
inlineprivate

Execute function when there is a single thread.

◆ thread_create_failed()

void ddl::Loader::Task_queue::thread_create_failed ( )
inlinenoexcept

Note that we failed to create the configured number of threads.

◆ validate()

bool ddl::Loader::Task_queue::validate ( ) const
inlinenoexcept
Returns
true if number of tasks submitted == number of tasks executed.

Member Data Documentation

◆ m_consumer_event

os_event_t ddl::Loader::Task_queue::m_consumer_event {}
private

Task queue consumer event.

◆ m_ctx

const Context& ddl::Loader::Task_queue::m_ctx
private

DDL context.

◆ m_mutex

ib_mutex_t ddl::Loader::Task_queue::m_mutex
private

Mutex protecting m_tasks access.

◆ m_n_idle

size_t ddl::Loader::Task_queue::m_n_idle {}
private

Number of threads idle.

◆ m_n_tasks_executed

size_t ddl::Loader::Task_queue::m_n_tasks_executed {}
private

Number of tasks executed.

◆ m_n_tasks_submitted

size_t ddl::Loader::Task_queue::m_n_tasks_submitted {}
private

Number of tasks submitted.

◆ m_n_threads

size_t ddl::Loader::Task_queue::m_n_threads {}
private

Number of threads (including foreground thread).

◆ m_sync

bool ddl::Loader::Task_queue::m_sync {}
private

true if synchronous execution model.

◆ m_tasks

Tasks ddl::Loader::Task_queue::m_tasks {}
private

The task queue.


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