Syntalos::WorkerEvents

Syntalos::WorkerEvents

Syntalos::WorkerEvents

Event registrations of an event-driven worker. More…

#include <moduleworker.h>

Public Classes

Name
structDataEvent
structTimedEvent
structOneShotEvent

Public Functions

Name
template <typename Fn >
void
onData(std::shared_ptr< VariantStreamSubscription > subscription, Fn && fn)
Call a function when the given subscription has received new data.
template <typename Fn >
void
every(const milliseconds_t & interval, Fn && fn)
Call a function at an interval.
template <typename Fn >
WorkerTimer
timer(Fn && fn)
Create a timer that calls a function once, some time after it was started.
const std::vector< DataEvent > &dataEvents() const
const std::vector< TimedEvent > &timedEvents() const
const std::vector< OneShotEvent > &oneShotEvents() const

Detailed Description

class Syntalos::WorkerEvents;

Event registrations of an event-driven worker.

Passed to the setup() function of a worker, which uses it to request callbacks in the event loop the module is assigned to. All callbacks of a worker are run by the same thread and never concurrently.

Public Functions Documentation

function onData

template <typename Fn >
inline void onData(
    std::shared_ptr< VariantStreamSubscription > subscription,
    Fn && fn
)

Call a function when the given subscription has received new data.

function every

template <typename Fn >
inline void every(
    const milliseconds_t & interval,
    Fn && fn
)

Call a function at an interval.

If the interval is 0, the function is called as soon as possible. The function receives a reference to its interval in milliseconds, which it may adjust to be run less or more frequently, or set to a negative value to not be called again. Since the function shares an event loop with other events, it will not be called in exactly the requested interval, and lost time is not caught up.

function timer

template <typename Fn >
inline WorkerTimer timer(
    Fn && fn
)

Create a timer that calls a function once, some time after it was started.

Unlike every(), which runs from the start of the run, the returned timer is started by the worker when it needs it, e.g. to do something a certain time after data has arrived.

function dataEvents

inline const std::vector< DataEvent > & dataEvents() const

function timedEvents

inline const std::vector< TimedEvent > & timedEvents() const

function oneShotEvents

inline const std::vector< OneShotEvent > & oneShotEvents() const

Updated on 2026-11-26 at 18:54:14 +0000