#include <task.hpp>
|
| | Task (std::function< ResultType()> function) |
| | Construct a new Task object. More...
|
| |
| void | execute () override |
| | Executes the task's function and sets the result in the promise. More...
|
| |
| ResultType | get () |
| | Retrieves the result of the task. More...
|
| |
| virtual | ~ITask ()=default |
| |
| virtual void | execute ()=0 |
| |
◆ Task()
template<typename ResultType >
| Task< ResultType >::Task |
( |
std::function< ResultType()> |
function | ) |
|
|
explicit |
Construct a new Task object.
This constructor initializes a new Task object with the provided function. The function will be executed when the task is run, and its result will be stored in a promise that can be accessed through the task's future. The function can be any callable object, such as a lambda, function pointer, or std::function
- Parameters
-
| function | The function to be executed as a task. This can be any callable object, such as a lambda, function pointer, or std::function |
◆ execute()
template<typename ResultType >
| void Task< ResultType >::execute |
|
overridevirtual |
Executes the task's function and sets the result in the promise.
This method is responsible for executing the task's function and then setting the result in the associated promise. If the function throws an exception, it will be caught and set as an exception in the promise instead
Implements ITask.
◆ get()
template<typename ResultType >
| ResultType Task< ResultType >::get |
Retrieves the result of the task.
This method blocks until the task has been completed and then returns the result. If the task's function threw an exception, this method will rethrow that exception when called
- Returns
- ResultType The result of the task, as produced by the task's function
◆ Exkit
template<typename ResultType >
The documentation for this class was generated from the following file: