uvw  2.2.0
Public Member Functions | List of all members
uvw::TimerHandle Class Referencefinal

The TimerHandle handle. More...

#include <timer.hpp>

Inheritance diagram for uvw::TimerHandle:
Inheritance graph
[legend]
Collaboration diagram for uvw::TimerHandle:
Collaboration graph
[legend]

Public Member Functions

bool init ()
 Initializes the handle. More...
 
void start (Time timeout, Time repeat)
 Starts the timer. More...
 
void stop ()
 Stops the handle.
 
void again ()
 Stops the timer and restarts it if it was repeating. More...
 
void repeat (Time repeat)
 Sets the repeat interval value. More...
 
Time repeat ()
 Gets the timer repeat value. More...
 
- Public Member Functions inherited from uvw::Handle< TimerHandle, uv_timer_t >
HandleCategory category () const noexcept override
 Gets the category of the handle. More...
 
HandleType type () const noexcept override
 Gets the type of the handle. More...
 
bool active () const noexcept override
 Checks if the handle is active. More...
 
bool closing () const noexcept override
 Checks if a handle is closing or closed. More...
 
void close () noexcept override
 Request handle to be closed. More...
 
void reference () noexcept override
 Reference the given handle. More...
 
void unreference () noexcept override
 Unreference the given handle. More...
 
bool referenced () const noexcept override
 Checks if the given handle referenced. More...
 
std::size_t size () const noexcept
 Returns the size of the underlying handle type. More...
 
int sendBufferSize ()
 Gets the size of the send buffer used for the socket. More...
 
bool sendBufferSize (int value)
 Sets the size of the send buffer used for the socket. More...
 
int recvBufferSize ()
 Gets the size of the receive buffer used for the socket. More...
 
bool recvBufferSize (int value)
 Sets the size of the receive buffer used for the socket. More...
 
OSFileDescriptor fileno () const
 Gets the platform dependent file descriptor equivalent. More...
 
- Public Member Functions inherited from uvw::UnderlyingType< TimerHandle, uv_timer_t >
Looploop () const noexcept
 Gets the loop from which the resource was originated. More...
 
const uv_timer_t * raw () const noexcept
 Gets the underlying raw data structure. More...
 
uv_timer_t * raw () noexcept
 Gets the underlying raw data structure. More...
 
- Public Member Functions inherited from uvw::Emitter< TimerHandle >
Connection< E > on (Listener< E > f)
 Registers a long-lived listener with the event emitter. More...
 
Connection< E > once (Listener< E > f)
 Registers a short-lived listener with the event emitter. More...
 
void erase (Connection< E > conn) noexcept
 Disconnects a listener from the event emitter. More...
 
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. More...
 
bool empty () const noexcept
 Checks if there are listeners registered with the event emitter. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from uvw::UnderlyingType< TimerHandle, uv_timer_t >
static std::shared_ptr< TimerHandlecreate (Args &&... args)
 Creates a new resource of the given type. More...
 

Detailed Description

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.

Definition at line 30 of file timer.hpp.

Member Function Documentation

◆ again()

void uvw::TimerHandle::again ( )
inline

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.

Definition at line 79 of file timer.hpp.

◆ init()

bool uvw::TimerHandle::init ( )
inline

Initializes the handle.

Returns
True in case of success, false otherwise.

Definition at line 45 of file timer.hpp.

◆ repeat() [1/2]

void uvw::TimerHandle::repeat ( Time  repeat)
inline

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.

Parameters
repeatRepeat interval in milliseconds (use std::chrono::duration<uint64_t, std::milli>).

Definition at line 101 of file timer.hpp.

◆ repeat() [2/2]

Time uvw::TimerHandle::repeat ( )
inline

Gets the timer repeat value.

Returns
Timer repeat value in milliseconds (as a std::chrono::duration<uint64_t, std::milli>).

Definition at line 110 of file timer.hpp.

◆ start()

void uvw::TimerHandle::start ( Time  timeout,
Time  repeat 
)
inline

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.

Parameters
timeoutMilliseconds before to emit an event (use std::chrono::duration<uint64_t, std::milli>).
repeatMilliseconds between successive events (use std::chrono::duration<uint64_t, std::milli>).

Definition at line 61 of file timer.hpp.


The documentation for this class was generated from the following file: