![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
Zero-overhead Task wrapper executing a stored callable. More...
#include <dfx-runtime/tasks/ASyncTask.hpp>
Public Member Functions | |
| ASyncTask (Func func, int priority=0) | |
Construct a task executing func. | |
| void | run () override |
| Execute the task. | |
| Public Member Functions inherited from dfx::Runtime::Task | |
| Task (int priority=0) | |
| Construct a task with a given scheduling priority. | |
| 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). | |
Zero-overhead Task wrapper executing a stored callable.
| Func | Callable type stored by value. Must not take any parameter and the return value is ignored. |
ASyncTask is a concrete Task implementation that wraps a callable object of type Func and invokes it in run().
Unlike a type-erased wrapper (e.g. std::function / std::move_only_function), this task is templated on the callable type and stores it directly. This yields:
Func itself is movable).This makes ASyncTask a good building block for the runtime Scheduler / ThreadPool, where many small work items are dispatched frequently and overhead matters.
|
inline |
Construct a task executing func.
The callable is stored by value (moved into the task).
| func | Callable to store and invoke when the task runs. |
| priority | Scheduling priority for this task (see Task::priority()). |
|
inlineoverridevirtual |
Execute the task.
Called by the runtime when the task is selected for execution. Implementations should keep execution time reasonable and avoid blocking indefinitely to prevent starving other work.
Implements dfx::Runtime::Task.