cmake-template
Loading...
Searching...
No Matches
Exkit Class Reference

#include <exkit.hpp>

Public Member Functions

 Exkit (IScheduler &scheduler)
 Construct a new Exkit object. More...
 
void run ()
 Executes all the registered tasks while respecting their dependencies. More...
 
template<typename DependentType , typename... DependencyTypes>
void add_dependency (TaskHandle< DependentType > &dependent, TaskHandle< DependencyTypes > &... dependencies)
 Adds a dependency between a dependent task and one or more dependency tasks. More...
 
template<typename FunctionType >
auto task (FunctionType &&function)
 Creates a new task with the given function. More...
 
template<typename FunctionType , typename... ResultTypes>
auto task (FunctionType &&function, TaskHandle< ResultTypes > &... dependencies)
 Creates a new task with the given function and specified dependencies. More...
 

Constructor & Destructor Documentation

◆ Exkit()

Exkit::Exkit ( IScheduler scheduler)

Construct a new Exkit object.

This constructor initializes the Exkit instance with a specified number of threads for executing tasks. If no thread count is provided, it defaults to the number of hardware threads available on the system, allowing for efficient parallel execution of tasks. The thread pool will be used to manage and execute tasks concurrently while respecting their dependencies

Parameters
thread_countThe number of threads to use for executing tasks. By default, this is set to the number of hardware threads available on the system

Member Function Documentation

◆ add_dependency()

template<typename DependentType , typename... DependencyTypes>
void Exkit::add_dependency ( TaskHandle< DependentType > &  dependent,
TaskHandle< DependencyTypes > &...  dependencies 
)

Adds a dependency between a dependent task and one or more dependency tasks.

This method is used to specify that a task (the dependent) depends on the completion of one or more other tasks (the dependencies). The dependent task will only be executed after all of its dependencies have been completed. This allows you to create complex task graphs where tasks can depend on the results of other tasks

Template Parameters
DependentTypeThe result type of the dependent task
DependencyTypesThe result types of the dependency tasks
Parameters
dependentThe handle of the dependent task
dependenciesThe handles of the dependency tasks

◆ run()

void Exkit::run ( )

Executes all the registered tasks while respecting their dependencies.

This method is used to start the execution of the tasks. It will block until all tasks have been completed. Tasks will be executed in an order that respects their dependencies, meaning that a task will only be executed after all of its dependencies have been completed. Also depending on the number of available threads, multiple tasks that are ready to execute may be run in parallel

◆ task() [1/2]

template<typename FunctionType >
auto Exkit::task ( FunctionType &&  function)

Creates a new task with the given function.

This method allows you to create a new task that will execute the provided function. The created task will not have any dependencies by default, but you can add dependencies to it later using the add_dependency method. The returned TaskHandle can be used to refer to the created task and its result, and can also be used as a dependency for other tasks

Template Parameters
FunctionTypeThe type of the function to be executed as a task
Parameters
functionThe function to be executed as a task. This can be any callable object, such as a lambda, function pointer, or std::function
Returns
auto A TaskHandle that can be used to refer to the created task and its result

◆ task() [2/2]

template<typename FunctionType , typename... ResultTypes>
auto Exkit::task ( FunctionType &&  function,
TaskHandle< ResultTypes > &...  dependencies 
)

Creates a new task with the given function and specified dependencies.

This method allows you to create a new task that depends on the completion of one or more other tasks. The provided function will be executed as a task, but only after all of the specified dependencies have been completed. The function can take the results of the dependency tasks as arguments, which will be automatically passed in when the task is executed

Template Parameters
FunctionTypeThe type of the function to be executed as a task
ResultTypesThe result types of the dependency tasks
Parameters
functionThe function to be executed as a task. This can be any callable object, such as a lambda, function pointer, or std::function
dependenciesThe handles of the tasks that this new task depends on. The new task will only be executed after all of these dependencies have been completed
Returns
auto A TaskHandle that can be used to refer to the created task and its result

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