![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
Task wrapper that executes a callable under a node lock and only if the node is still alive. More...
#include <dfx-runtime/tasks/NodeTask.hpp>
Public Member Functions | |
| NodeTask (Func func, Core::NodeWPtr node, int priority=0) | |
| Construct a node-bound task. | |
| void | run () override |
| Execute the callable if the node is still alive, under the node lock. | |
| 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). | |
Task wrapper that executes a callable under a node lock and only if the node is still alive.
| Func | Callable type stored by value. Must be invocable as Func(Core::NodePtr) and the return value is ignored. |
NodeTask is a concrete Task implementation used to execute work in a node-aware way.
It exists to support the runtime scheduling model where:
Compared to a generic task (e.g. ASyncTask), NodeTask adds two guarantees:
This makes NodeTask the natural "dispatch unit" used by runtime components such as the dfx::Runtime::Scheduler / dfx::Runtime::Api::NodeReactor integration: they can enqueue node-bound work safely, even with many worker threads.
|
inline |
Construct a node-bound task.
The node is stored as a weak pointer and is validated at execution time.
| func | Callable executed when the task runs (under the node lock). |
| node | Weak reference to the target node. |
| priority | Scheduling priority for this task (see Task::priority()). |
|
inlineoverridevirtual |
Execute the callable if the node is still alive, under the node lock.
Note that since the node lock is a recursive one, it is perfectly safe and valid for the same thread to re-enter the node through an inline call.
Implements dfx::Runtime::Task.