uvw 2.12.1
|
The TimerHandle handle. More...
#include <timer.h>
Public Member Functions | |
bool | init () |
Initializes the handle. | |
void | start (Time timeout, Time repeat) |
Starts the timer. | |
void | stop () |
Stops the handle. | |
void | again () |
Stops the timer and restarts it if it was repeating. | |
void | repeat (Time repeat) |
Sets the repeat interval value. | |
Time | repeat () |
Gets the timer repeat value. | |
Time | dueIn () |
Gets the timer due value. | |
![]() | |
HandleCategory | category () const noexcept |
Gets the category of the handle. | |
HandleType | type () const noexcept |
Gets the type of the handle. | |
bool | active () const noexcept |
Checks if the handle is active. | |
bool | closing () const noexcept |
Checks if a handle is closing or closed. | |
void | close () noexcept |
Request handle to be closed. | |
void | reference () noexcept |
Reference the given handle. | |
void | unreference () noexcept |
Unreference the given handle. | |
bool | referenced () const noexcept |
Checks if the given handle referenced. | |
std::size_t | size () const noexcept |
Returns the size of the underlying handle type. | |
int | sendBufferSize () |
Gets the size of the send buffer used for the socket. | |
bool | sendBufferSize (int value) |
Sets the size of the send buffer used for the socket. | |
int | recvBufferSize () |
Gets the size of the receive buffer used for the socket. | |
bool | recvBufferSize (int value) |
Sets the size of the receive buffer used for the socket. | |
OSFileDescriptor | fd () const |
Gets the platform dependent file descriptor equivalent. | |
![]() | |
std::shared_ptr< R > | data () const |
Gets user-defined data. uvw won't use this field in any case. | |
void | data (std::shared_ptr< void > uData) |
Sets arbitrary data. uvw won't use this field in any case. | |
![]() | |
Loop & | loop () const noexcept |
Gets the loop from which the resource was originated. | |
const uv_timer_t * | raw () const noexcept |
Gets the underlying raw data structure. | |
uv_timer_t * | raw () noexcept |
Gets the underlying raw data structure. | |
![]() | |
Connection< E > | on (Listener< E > f) |
Registers a long-lived listener with the event emitter. | |
Connection< E > | once (Listener< E > f) |
Registers a short-lived listener with the event emitter. | |
void | erase (Connection< E > conn) noexcept |
Disconnects a listener from the event emitter. | |
void | clear () noexcept |
Disconnects all the listeners for the given event type. | |
void | clear () noexcept |
Disconnects all the listeners. | |
bool | empty () const noexcept |
Checks if there are listeners registered for the specific event. | |
bool | empty () const noexcept |
Checks if there are listeners registered with the event emitter. | |
Additional Inherited Members | |
![]() | |
![]() | |
static std::shared_ptr< TimerHandle > | create (Args &&...args) |
Creates a new resource of the given type. | |
![]() | |
![]() | |
![]() | |
![]() | |
![]() | |
![]() |
The TimerHandle handle.
Timer handles are used to schedule events to be emitted in the future.
To create a TimerHandle
through a Loop
, no arguments are required.
void uvw::TimerHandle::again | ( | ) |
Stops the timer and restarts it if it was repeating.
Stop the timer, and if it is repeating restart it using the repeat value as the timeout.
If the timer has never been started before it emits an ErrorEvent event.
Time uvw::TimerHandle::dueIn | ( | ) |
Gets the timer due value.
The time is relative to Loop::now()
.
bool uvw::TimerHandle::init | ( | ) |
Initializes the handle.
Time uvw::TimerHandle::repeat | ( | ) |
Gets the timer repeat value.
std::chrono::duration<uint64_t, std::milli>
). void uvw::TimerHandle::repeat | ( | Time | repeat | ) |
Sets the repeat interval value.
The timer will be scheduled to run on the given interval and will follow normal timer semantics in the case of a time-slice overrun.
For example, if a 50ms repeating timer first runs for 17ms, it will be scheduled to run again 33ms later. If other tasks consume more than the 33ms following the first timer event, then another event will be emitted as soon as possible.
If the repeat value is set from a listener bound to an event, it does not immediately take effect. If the timer was non-repeating before, it will have been stopped. If it was repeating, then the old repeat value will have been used to schedule the next timeout.
repeat | Repeat interval in milliseconds (use std::chrono::duration<uint64_t, std::milli> ). |
void uvw::TimerHandle::start | ( | Time | timeout, |
Time | repeat ) |
Starts the timer.
If timeout is zero, a TimerEvent event is emitted on the next event loop iteration. If repeat is non-zero, a TimerEvent event is emitted first after timeout milliseconds and then repeatedly after repeat milliseconds.
timeout | Milliseconds before to emit an event (use std::chrono::duration<uint64_t, std::milli> ). |
repeat | Milliseconds between successive events (use std::chrono::duration<uint64_t, std::milli> ). |