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) {
71 std::function<
void()> func) {
139 #endif // WPIUTIL_WPI_UV_TIMER_H_
uv_timer_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:288
void Again()
Stop the timer and restart it if it was repeating.
Definition: Timer.h:101
void Stop()
Stop the timer.
Definition: Timer.h:92
static std::shared_ptr< Timer > Create(Loop &loop)
Create a timer handle.
WPILib C++ utilities (wpiutil) namespace.
Definition: EventLoopRunner.h:17
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
Handle.
Definition: Handle.h:273
Timer handle.
Definition: Timer.h:29
Time GetRepeat() const
Get the timer repeat value.
Definition: Timer.h:128
sig::Signal timeout
Signal generated when the timeout event occurs.
Definition: Timer.h:133
Event loop.
Definition: Loop.h:39
void SetRepeat(Time repeat)
Set the repeat interval value.
Definition: Timer.h:121
void Start(Time timeout, Time repeat=Time{0})
Start the timer.
static std::shared_ptr< Timer > Create(const std::shared_ptr< Loop > &loop)
Create a timer handle.
Definition: Timer.h:50
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
static void SingleShot(Loop &loop, Time timeout, std::function< void()> func)
Create a timer that calls a functor after a given time interval.