![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
A task implementation that wraps a callable object and provides a future for the result. More...
#include <dfx-runtime/tasks/PackagedTask.hpp>
Public Member Functions | |
| template<typename Func> requires (!std::same_as<PackagedTask, std::remove_cvref_t<Func>>) | |
| PackagedTask (Func &&func, int priority=0) | |
| Constructs a new PackagedTask object. | |
| std::future< R > | getFuture () |
| Gets a future associated with the task's result. | |
| void | run () override |
| Executes the wrapped task. | |
| Public Member Functions inherited from dfx::Runtime::Api::Task | |
| Task (int priority=0) | |
| Construct a task with a given scheduling priority. | |
| DFX_DISABLE_COPY_AND_MOVE (Task) | |
| Tasks are neither copyable nor movable. | |
| virtual | ~Task ()=default |
| Polymorphic base requires a virtual destructor. | |
| int | priority () const noexcept |
| Task scheduling priority. | |
| template<DerivedFromTask T> | |
| T & | as () |
| Unchecked downcast to a concrete task type. | |
| template<DerivedFromTask T> | |
| T const & | as () const |
| Unchecked downcast to a concrete task type (const overload). | |
A task implementation that wraps a callable object and provides a future for the result.
PackagedTask inherits from the dfx Runtime API Task and integrates with std::future. It allows a callable (function, lambda, etc.) to be executed asynchronously by the runtime while allowing the caller to retrieve the result at a later time.
| R | The return type of the task. |
|
inlineexplicit |
Constructs a new PackagedTask object.
| Func | The type of the callable object. |
| func | The callable object to be executed. |
| priority | The execution priority of the task (defaults to 0). |
|
inline |
Gets a future associated with the task's result.
|
inlineoverridevirtual |
Executes the wrapped task.
Overrides the pure virtual run() method from Api::Task. This invokes the underlying std::packaged_task.
Implements dfx::Runtime::Api::Task.