8 #ifndef WPIUTIL_WPI_UV_TIMER_H_
9 #define WPIUTIL_WPI_UV_TIMER_H_
17 #include "wpi/Signal.h"
18 #include "wpi/uv/Handle.h"
30 struct private_init {};
33 using Time = std::chrono::duration<uint64_t, std::milli>;
35 explicit Timer(
const private_init&) {}
36 ~
Timer() noexcept
override =
default;
43 static std::shared_ptr<Timer>
Create(
Loop& loop);
50 static std::shared_ptr<Timer>
Create(
const std::shared_ptr<Loop>& loop) {
70 static void SingleShot(
const std::shared_ptr<Loop>& loop, Time timeout,
71 std::function<
void()> func) {
87 void Start(Time timeout, Time repeat = Time{0});
139 #endif // WPIUTIL_WPI_UV_TIMER_H_
void SetRepeat(Time repeat)
Set the repeat interval value.
Definition: Timer.h:121
uv_timer_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:261
void Start(Time timeout, Time repeat=Time{0})
Start the timer.
Handle.
Definition: Handle.h:246
static void SingleShot(Loop &loop, Time timeout, std::function< void()> func)
Create a timer that calls a functor after a given time interval.
Time GetRepeat() const
Get the timer repeat value.
Definition: Timer.h:128
void Again()
Stop the timer and restart it if it was repeating.
Definition: Timer.h:101
static void SingleShot(const std::shared_ptr< Loop > &loop, Time timeout, std::function< void()> func)
Create a timer that calls a functor after a given time interval.
Definition: Timer.h:70
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
void Stop()
Stop the timer.
Definition: Timer.h:92
static std::shared_ptr< Timer > Create(Loop &loop)
Create a timer handle.
Event loop.
Definition: Loop.h:39
static std::shared_ptr< Timer > Create(const std::shared_ptr< Loop > &loop)
Create a timer handle.
Definition: Timer.h:50
Timer handle.
Definition: Timer.h:29
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
sig::Signal timeout
Signal generated when the timeout event occurs.
Definition: Timer.h:133