Notifiers run a user-provided callback function on a separate thread.
More...
#include <wpi/system/Notifier.hpp>
|
| | Notifier (std::function< void()> callback) |
| | Create a Notifier with the given callback.
|
| template<typename Arg, typename... Args> |
| | Notifier (std::invocable< Arg, Args... > auto &&callback, Arg &&arg, Args &&... args) |
| | Notifier (int priority, std::function< void()> callback) |
| | Create a Notifier with the given callback.
|
| template<typename Arg, typename... Args> |
| | Notifier (int priority, std::invocable< Arg, Args... > auto &&callback, Arg &&arg, Args &&... args) |
| | ~Notifier () |
| | Free the resources for a timer event.
|
| | Notifier (Notifier &&rhs) |
| Notifier & | operator= (Notifier &&rhs) |
| void | SetName (std::string_view name) |
| | Sets the name of the notifier.
|
| void | SetCallback (std::function< void()> callback) |
| | Change the callback function.
|
| void | StartSingle (wpi::units::second_t delay) |
| | Run the callback once after the given delay.
|
| void | StartPeriodic (wpi::units::second_t period) |
| | Run the callback periodically with the given period.
|
| void | StartPeriodic (wpi::units::hertz_t frequency) |
| | Run the callback periodically with the given frequency.
|
| void | Stop () |
| | Stop further callback invocations.
|
| int32_t | GetOverrun () const |
| | Gets the overrun count.
|
Notifiers run a user-provided callback function on a separate thread.
If StartSingle() is used, the callback will run once. If StartPeriodic() is used, the callback will run repeatedly with the given period until stop() is called.
◆ Notifier() [1/5]
| wpi::Notifier::Notifier |
( |
std::function< void()> | callback | ) |
|
|
inlineexplicit |
◆ Notifier() [2/5]
template<typename Arg, typename... Args>
| wpi::Notifier::Notifier |
( |
std::invocable< Arg, Args... > auto && | callback, |
|
|
Arg && | arg, |
|
|
Args &&... | args ) |
|
inline |
◆ Notifier() [3/5]
| wpi::Notifier::Notifier |
( |
int | priority, |
|
|
std::function< void()> | callback ) |
|
explicit |
Create a Notifier with the given callback.
Configure when the callback runs with StartSingle() or StartPeriodic().
This overload makes the underlying thread run with a real-time priority. This is useful for reducing scheduling jitter on processes which are sensitive to timing variance, like model-based control.
- Parameters
-
| priority | The FIFO real-time scheduler priority ([1..99] where a higher number represents higher priority). See "man 7
sched" for more details. |
| callback | The callback to run. |
◆ Notifier() [4/5]
template<typename Arg, typename... Args>
| wpi::Notifier::Notifier |
( |
int | priority, |
|
|
std::invocable< Arg, Args... > auto && | callback, |
|
|
Arg && | arg, |
|
|
Args &&... | args ) |
|
inline |
◆ ~Notifier()
| wpi::Notifier::~Notifier |
( |
| ) |
|
Free the resources for a timer event.
◆ Notifier() [5/5]
| wpi::Notifier::Notifier |
( |
Notifier && | rhs | ) |
|
◆ GetOverrun()
| int32_t wpi::Notifier::GetOverrun |
( |
| ) |
const |
Gets the overrun count.
An overrun occurs when a notifier's alarm is not serviced before the next scheduled alarm time.
- Returns
- overrun count
◆ operator=()
◆ SetCallback()
| void wpi::Notifier::SetCallback |
( |
std::function< void()> | callback | ) |
|
Change the callback function.
- Parameters
-
| callback | The callback function. |
◆ SetName()
| void wpi::Notifier::SetName |
( |
std::string_view | name | ) |
|
Sets the name of the notifier.
Used for debugging purposes only.
- Parameters
-
◆ StartPeriodic() [1/2]
| void wpi::Notifier::StartPeriodic |
( |
wpi::units::hertz_t | frequency | ) |
|
Run the callback periodically with the given frequency.
The user-provided callback should be written so that it completes before the next time it's scheduled to run.
- Parameters
-
| frequency | Frequency after which to call the callback starting one period after the call to this method. |
◆ StartPeriodic() [2/2]
| void wpi::Notifier::StartPeriodic |
( |
wpi::units::second_t | period | ) |
|
Run the callback periodically with the given period.
The user-provided callback should be written so that it completes before the next time it's scheduled to run.
- Parameters
-
| period | Period after which to call the callback starting one period after the call to this method. |
◆ StartSingle()
| void wpi::Notifier::StartSingle |
( |
wpi::units::second_t | delay | ) |
|
Run the callback once after the given delay.
- Parameters
-
| delay | Time to wait before the callback is called. |
◆ Stop()
| void wpi::Notifier::Stop |
( |
| ) |
|
Stop further callback invocations.
No further periodic callbacks will occur. Single invocations will also be cancelled if they haven't yet occurred.
If a callback invocation is in progress, this function will block until the callback is complete.
The documentation for this class was generated from the following file: