Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::TaskExecutor Class Reference

The TaskExecutor is a helper class that enables parallel scheduling and execution of tasks. More...

Collaboration diagram for duckdb::TaskExecutor:

Public Member Functions

 TaskExecutor (ClientContext &context)
 TaskExecutor (TaskScheduler &scheduler)
void PushError (ErrorData error)
 Push an error into the TaskExecutor.
bool HasError ()
 Whether or not any task has encountered an error.
void ThrowError ()
 Throw an error that was encountered during execution (if HasError() is true).
void ScheduleTask (unique_ptr< Task > task)
 Schedule a new task.
void FinishTask ()
 Label a task as finished.
void WorkOnTasks ()
 Work on tasks until all tasks are finished. Throws an exception if any error occurred while executing the tasks.
bool GetTask (shared_ptr< Task > &task)
 Get a task - returns true if a task was found.

Private Attributes

TaskScheduler & scheduler
TaskErrorManager error_manager
unique_ptr< ProducerToken > token
atomic< idx_t > completed_tasks
atomic< idx_t > total_tasks
optional_ptr< ClientContext > context

Friends

class BaseExecutorTask

Detailed Description

The TaskExecutor is a helper class that enables parallel scheduling and execution of tasks.

Constructor & Destructor Documentation

◆ TaskExecutor() [1/2]

duckdb::TaskExecutor::TaskExecutor ( ClientContext & context)
explicit
330691 : TaskExecutor(TaskScheduler::GetScheduler(context_p)) {
330692 context = context_p;
330693}

◆ TaskExecutor() [2/2]

duckdb::TaskExecutor::TaskExecutor ( TaskScheduler & scheduler)
explicit
330688 : scheduler(scheduler), token(scheduler.CreateProducer()), completed_tasks(0), total_tasks(0) {
330689}

◆ ~TaskExecutor()

duckdb::TaskExecutor::~TaskExecutor ( )
330695 {
330696}

Member Function Documentation

◆ PushError()

void duckdb::TaskExecutor::PushError ( ErrorData error)

Push an error into the TaskExecutor.

330698 {
330699 error_manager.PushError(std::move(error));
330700}

◆ HasError()

bool duckdb::TaskExecutor::HasError ( )

Whether or not any task has encountered an error.

330702 {
330703 return error_manager.HasError();
330704}
Here is the caller graph for this function:

◆ ThrowError()

void duckdb::TaskExecutor::ThrowError ( )

Throw an error that was encountered during execution (if HasError() is true).

330706 {
330707 error_manager.ThrowException();
330708}
Here is the caller graph for this function:

◆ ScheduleTask()

void duckdb::TaskExecutor::ScheduleTask ( unique_ptr< Task > task)

Schedule a new task.

330710 {
330711 ++total_tasks;
330712 scheduler.ScheduleTask(*token, std::move(task));
330713}
Here is the caller graph for this function:

◆ FinishTask()

void duckdb::TaskExecutor::FinishTask ( )

Label a task as finished.

330714 {
330715 ++completed_tasks;
330716}
Here is the caller graph for this function:

◆ WorkOnTasks()

void duckdb::TaskExecutor::WorkOnTasks ( )

Work on tasks until all tasks are finished. Throws an exception if any error occurred while executing the tasks.

330718 {
330719 // repeatedly execute tasks until we are finished
330720 shared_ptr<Task> task_from_producer;
330721 while (scheduler.GetTaskFromProducer(*token, task_from_producer)) {
330722 auto res = task_from_producer->Execute(TaskExecutionMode::PROCESS_ALL);
330723 (void)res;
330724 D_ASSERT(res != TaskExecutionResult::TASK_BLOCKED);
330725 task_from_producer.reset();
330726 }
330727 // wait for all active tasks to finish
330728 while (completed_tasks != total_tasks) {
330729 }
330730
330731 // check if we ran into any errors while checkpointing
330732 if (HasError()) {
330733 // throw the error
330734 ThrowError();
330735 }
330736}
bool HasError()
Whether or not any task has encountered an error.
Definition duckdb.cpp:330702
void ThrowError()
Throw an error that was encountered during execution (if HasError() is true).
Definition duckdb.cpp:330706
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTask()

bool duckdb::TaskExecutor::GetTask ( shared_ptr< Task > & task)

Get a task - returns true if a task was found.

330738 {
330739 return scheduler.GetTaskFromProducer(*token, task);
330740}

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