135 explicit Config(uint32_t _delay_ms, uint16_t _priority = 0, uint32_t _schedule_timeout_ms = 0,
136 uint32_t _execution_timeout_ms = 0);
RAII handle returned by exec_task() for a bool-returning callback task.
Definition schedule.h:249
Status()
Constructs an invalid Status (not yet associated with a task).
Status & on_else(Callback &&callback)
Registers a callback fired when the task returns false.
RetStatus & on_then(RetCallback &&callback)
Registers a callback chain element fired when the task returns true.
RAII handle returned by exec_task() for a void-callback task.
Definition schedule.h:152
Status & operator=(Status &&status) noexcept
Move assignment.
Status & operator=(const Status &)=delete
Status & on_execution_timeout(Callback &&callback)
Registers a callback fired when the task runs longer than execution_timeout_ms.
Status & on_catch(CatchCallback &&callback)
Registers a callback fired when the task throws an exception.
Status & on_schedule_timeout(Callback &&callback)
Registers a callback fired when the task does not start within schedule_timeout_ms.
Status(Status &&status) noexcept
Move constructor.
std::shared_ptr< StatusImpl > impl_
Definition schedule.h:238
Status()
Constructs an invalid Status (not yet associated with a task).
friend Schedule
Definition schedule.h:226
void set_valid(bool valid)
Sets whether the status is valid (task was successfully posted).
bool is_valid() const
Returns true if the associated task was posted successfully.
Status(const Status &)=delete
Platform-independent macro definitions for the VLink library.
#define VLINK_EXPORT
Definition macros.h:85
Scheduling parameters for a task posted via MessageLoop::exec_task().
Definition schedule.h:121
Config()
Constructs a default Config with all fields set to zero.
uint32_t schedule_timeout_ms
Max ms to wait before task starts. 0 = disabled.
Definition schedule.h:140
Config(uint32_t _delay_ms, uint16_t _priority=0, uint32_t _schedule_timeout_ms=0, uint32_t _execution_timeout_ms=0)
Constructs a Config with all fields specified.
uint32_t delay_ms
Delay in ms before the task is posted.
Definition schedule.h:138
uint32_t execution_timeout_ms
Max ms the task may execute. 0 = disabled.
Definition schedule.h:141
uint16_t priority
Dispatch priority (higher = sooner).
Definition schedule.h:139
Definition schedule.h:228
Callback else_callback
Definition schedule.h:234
CatchCallback catch_callback
Definition schedule.h:233
Callback schedule_timeout_callback
Definition schedule.h:231
Callback execution_timeout_callback
Definition schedule.h:232
std::atomic_bool is_valid
Definition schedule.h:229
std::recursive_mutex mtx
Definition schedule.h:230
std::vector< RetCallback > then_callback_list
Definition schedule.h:235
static Status process(const Config &config, Callback &&callback, Callback &wrapper_callback)
Wraps a void callback in a Config envelope and produces a wrapper task.
std::function< bool()> RetCallback
Callback type for tasks that return a boolean result.
Definition schedule.h:107
Schedule & operator=(const Schedule &)=delete
std::function< void(std::exception &)> CatchCallback
Callback type invoked when an exception is caught inside the task.
Definition schedule.h:112
std::function< void()> Callback
Callback type for void tasks and lifecycle hooks (schedule/execution timeout, else).
Definition schedule.h:102
Schedule(Schedule &&)=delete
Schedule & operator=(Schedule &&)=delete
Schedule(const Schedule &)=delete
static RetStatus process_with_ret(const Config &config, RetCallback &&callback, Callback &wrapper_callback)
Wraps a bool-returning callback in a Config envelope and produces a wrapper task.