openDAQ
Open data acquisition platform
+ Collaboration diagram for Scheduler:

Detailed Description

Modules

 Factories
 

Functions

daq::AwaitablePtr scheduleFunction (const daq::FunctionPtr &function) const
 Schedules the specified work function to run on the thread-pool. The call does not block but immediately returns an awaitable that represents the asynchronous execution. It can be waited upon and queried for status and result. More...
 
void scheduleWork (const daq::WorkPtr &work) const
 Schedules the specified work callback to run on the thread-pool. The call does not block. More...
 
daq::AwaitablePtr scheduleGraph (const daq::TaskGraphPtr &graph) const
 Schedules the specified dependency graph to run on the thread-pool. The call does not block but immediately returns an awaitable that represents the asynchronous execution. It can be waited upon and queried for status and result. Any exceptions that occur during the graph execution are silently ignored. More...
 
void stop () const
 Cancels all outstanding work and waits for the remaining to complete. After this point the scheduler does not allow any new work or graphs for scheduling.
 
void waitAll () const
 Waits fo all current scheduled work and tasks to complete.
 
daq::Bool isMultiThreaded () const
 Returns whether more than one worker thread is used. More...
 
void runMainLoop (daq::SizeT loopTime=1) const
 Starts and blocks the main event loop, executing scheduled tasks. More...
 
daq::Bool isMainLoopSet () const
 Checks if the main loop is currently set. More...
 
void stopMainLoop () const
 Signals the main loop to stop processing and return from runMainLoop. This method unblocks the loop and requests graceful shutdown. It is typically called from another thread or in response to an application shutdown signal. Has no effect if the loop is not currently running.
 
void runMainLoopIteration () const
 Executes a single iteration of the main loop, processing scheduled tasks. More...
 
void scheduleWorkOnMainLoop (const daq::WorkPtr &work) const
 Schedules a task to be executed by the main loop. More...
 

Function Documentation

◆ isMainLoopSet()

daq::Bool isMainLoopSet ( ) const
inline

Checks if the main loop is currently set.

Returns
Returns true if the main loop is set and running. This method does not gauarantee that the main loop is currently running, only that it has been set up.

◆ isMultiThreaded()

daq::Bool isMultiThreaded ( ) const
inline

Returns whether more than one worker thread is used.

Returns
Returns true if more that one worker thread is used by the scheduler.

◆ runMainLoop()

void runMainLoop ( daq::SizeT  loopTime = 1) const
inline

Starts and blocks the main event loop, executing scheduled tasks.

Parameters
loopTimeThe maximum time to block the loop, in milliseconds.

This method runs the main loop, processing all enqueued work (including repetitive tasks) until stopMainLoop is called. Typically executed on the main thread or in a dedicated loop thread.

◆ runMainLoopIteration()

void runMainLoopIteration ( ) const
inline

Executes a single iteration of the main loop, processing scheduled tasks.

This non-blocking method runs one iteration of the main loop, executing one-time tasks and advancing any repetitive tasks. Intended for cases where the main loop is polled manually, such as in GUI frameworks or embedded systems.

◆ scheduleFunction()

daq::AwaitablePtr scheduleFunction ( const daq::FunctionPtr &  function) const
inline

Schedules the specified work function to run on the thread-pool. The call does not block but immediately returns an awaitable that represents the asynchronous execution. It can be waited upon and queried for status and result.

Parameters
functionThe function to schedule for execution.
Returns
The object representing the state and result of the execution.
Exceptions
OpendaqErrExceptionwhen the scheduler already stopped and is not accepting any more work.

◆ scheduleGraph()

daq::AwaitablePtr scheduleGraph ( const daq::TaskGraphPtr &  graph) const
inline

Schedules the specified dependency graph to run on the thread-pool. The call does not block but immediately returns an awaitable that represents the asynchronous execution. It can be waited upon and queried for status and result. Any exceptions that occur during the graph execution are silently ignored.

Parameters
graphThe dependency graph (acyclic directed graph) to schedule.
Returns
The object representing the state and result of the execution.
Exceptions
OpendaqErrExceptionwhen the scheduler already stopped and is not accepting any more work.

◆ scheduleWork()

void scheduleWork ( const daq::WorkPtr &  work) const
inline

Schedules the specified work callback to run on the thread-pool. The call does not block.

Parameters
workThe function to schedule for execution.
Exceptions
OpendaqErrExceptionwhen the scheduler already stopped and is not accepting any more work.

Work is a lightweight callback that returns no value and accepts no procedure. It has less overhead than function. The function does not return awaitable object.

◆ scheduleWorkOnMainLoop()

void scheduleWorkOnMainLoop ( const daq::WorkPtr &  work) const
inline

Schedules a task to be executed by the main loop.

The provided work object is queued for execution during a call to either runMainLoop or runMainLoopIteration. This mechanism is commonly used to marshal tasks from background threads to the main loop thread.

Parameters
workA lightweight, non-blocking task object to be scheduled.