dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::Core::CustomExecutor Class Reference

A priority-aware implementation of the NodeTaskExecutor interface. More...

#include <dfx-core/CustomExecutor.hpp>

Inheritance diagram for dfx::Core::CustomExecutor:
[legend]
Collaboration diagram for dfx::Core::CustomExecutor:
[legend]

Public Member Functions

bool pushTask (Runtime::Api::TaskPtr task) override
 Pushes a task into the priority-stable execution queue.
std::size_t pushTasks (std::span< Runtime::Api::TaskPtr > tasks) override
 Pushes a batch of tasks into the execution queue.
void processNextTask ()
 Consumes and executes the single highest-priority task currently in the queue.
void processAllPendingTasks ()
 Drains the entire queue, executing all pending tasks in priority order.
Public Member Functions inherited from dfx::Runtime::Api::NodeTaskExecutor
virtual ~NodeTaskExecutor ()=default
 Virtual destructor.

Detailed Description

A priority-aware implementation of the NodeTaskExecutor interface.

CustomExecutor provides a mechanism to redirect node task execution into a private, priority-stable queue. This is particularly useful for nodes that require specific execution ordering or need to manage task processing on a specific thread (e.g., a UI thread or a dedicated IO thread).

The "Consumer" side of the queue is manually triggered via processNextTask or processAllPendingTasks.

The internal queue is unbounded meaning that an "infinite" number of task can be pushed to it which can lead to an OOM if task arn't consumed.

Member Function Documentation

◆ processAllPendingTasks()

void dfx::Core::CustomExecutor::processAllPendingTasks ( )

Drains the entire queue, executing all pending tasks in priority order.

This method continues processing until the queue is empty.

◆ processNextTask()

void dfx::Core::CustomExecutor::processNextTask ( )

Consumes and executes the single highest-priority task currently in the queue.

This method should be called by the thread "owning" the execution context (e.g., inside a loop or a timer callback). If the queue is empty, this operation does nothing.

◆ pushTask()

bool dfx::Core::CustomExecutor::pushTask ( Runtime::Api::TaskPtr task)
overridevirtual

Pushes a task into the priority-stable execution queue.

Parameters
taskThe task to be executed.
Returns
always true.
Note
This method is thread-safe and non-blocking.

Implements dfx::Runtime::Api::NodeTaskExecutor.

◆ pushTasks()

std::size_t dfx::Core::CustomExecutor::pushTasks ( std::span< Runtime::Api::TaskPtr > tasks)
overridevirtual

Pushes a batch of tasks into the execution queue.

Optimizes enqueueing by minimizing locking overhead for multiple tasks.

Parameters
tasksA span of task pointers to be enqueued.
Returns
The number of tasks successfully added to the queue.

Implements dfx::Runtime::Api::NodeTaskExecutor.


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