Timeout#
Core Functionality#
Defined in namespace hal
#include <libhal/timeout.hpp>
- group TimeoutCore
Typedefs
-
using timeout_function = void(void) noexcept(false)#
Signature of a function that throws hal::timed_out.
A function that expires after a certain amount of time or after a certain amount of events, or after a specific event occurs. When called, this function checks if the expiration event has occurred and if so, throws the exception hal::timed_out.
- Throws hal::timed_out:
- to indicate that it has expired
-
using work_function = work_state()#
A non-blocking callable that performs work with each call.
Each call to a work_function will perform a set of work. The worker will return a work_state to indicate its current state. Once the worker reaches a terminal state, it MUST perform no additional work and return the terminal state. For example, if a work function failed, it must always return failure and not interact with hardware or other software from that point on. Same will occur for the βfinishedβ state.
This function can be repeatedly tried until it has reached a terminal state with the try_until() function.
- Return:
work_state - indicates what the state of the worker function is.
Enums
Functions
-
inline auto never_timeout()#
Create a timeout that will never time out.
- Returns:
auto - callable that will never timeout
-
using timeout_function = void(void) noexcept(false)#
Utilities#
Defined in namespace hal
#include <libhal-util/timeout.hpp>
- group TimeoutUtil
Functions
-
inline work_state try_until(worker auto &p_worker, timeout auto p_timeout)#
Repeatedly call a worker function until it has reached a terminal state or a timeout has been reached.
- Parameters:
p_worker β - worker function to repeatedly call
p_timeout β - callable timeout object
- Returns:
work_state - state of the worker function
-
inline work_state try_until(worker auto &&p_worker, timeout auto p_timeout)#
Repeatedly call a worker function until it has reached a terminal state or a timeout has been reached.
- Parameters:
p_worker β - worker function to repeatedly call
p_timeout β - callable timeout object
- Returns:
work_state - state of the worker function
-
inline work_state try_until(worker auto &p_worker, timeout auto p_timeout)#