dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::Runtime::Api::NodeTaskExecutor Class Referenceabstract

Interface for offloading task execution from the global pool to a specific node context. More...

#include <dfx-runtime-api/NodeTaskExecutor.hpp>

Inheritance diagram for dfx::Runtime::Api::NodeTaskExecutor:
[legend]

Public Member Functions

virtual ~NodeTaskExecutor ()=default
 Virtual destructor.
virtual bool pushTask (TaskPtr task)=0
 Pushes a task into the node's private execution queue.
virtual std::size_t pushTasks (std::span< TaskPtr > tasks)=0
 Pushes a list of task into the node's private execution queue.

Detailed Description

Interface for offloading task execution from the global pool to a specific node context.

Some nodes require strict thread affinity or internal synchronization that is incompatible with the default runtime thread pool. By implementing this interface, a node can "hijack" its own task execution.

Relationship with NodeReactor
When a NodeTaskExecutor is assigned to a node in the NodeReactor, the reactor will forward all events (FD readiness, deferred calls) to pushTask (or pushTasks) instead of scheduling them on generic worker threads.
Note
This interface only defines the 'Producer' side of the queue used by the NodeReactor. The 'Consumer' side (processing/running tasks) is managed privately by the Node.
The Core::Node::start and Core::Node::stop operations are never done in this NodeTaskExecutor since it is assumed that the executor will only be ready after the call to start is completed.

Constructor & Destructor Documentation

◆ ~NodeTaskExecutor()

virtual dfx::Runtime::Api::NodeTaskExecutor::~NodeTaskExecutor ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ pushTask()

virtual bool dfx::Runtime::Api::NodeTaskExecutor::pushTask ( TaskPtr task)
pure virtual

Pushes a task into the node's private execution queue.

This method is called by the dfx::Runtime::Api::NodeReactor when an event associated with the node triggers. It is expected to be non-blocking and thread-safe, as it will typically be called from the reactor's polling thread.

Parameters
taskThe task to be executed by the node.
Returns
true if the task was successfully enqueued; false otherwise (e.g., buffer full).

Implemented in dfx::Core::CustomExecutor, and dfx::Plugins::CNodeExecutor.

◆ pushTasks()

virtual std::size_t dfx::Runtime::Api::NodeTaskExecutor::pushTasks ( std::span< TaskPtr > tasks)
pure virtual

Pushes a list of task into the node's private execution queue.

This method is similar to pushTask but can push more than 1 task at a time which may allow for locking optimization.

Parameters
tasksThe list of tasks to be executed by the node.
Returns
The number of task successfully pushed for execution.

Implemented in dfx::Core::CustomExecutor, and dfx::Plugins::CNodeExecutor.


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