boost::corosio::timer

An asynchronous timer for coroutine I/O.

Synopsis

Declared in <boost/corosio/timer.hpp>

class timer
    : public io_object

Description

This class provides asynchronous timer operations that return awaitable types. The timer can be used to schedule operations to occur after a specified duration or at a specific time point.

Each timer operation participates in the affine awaitable protocol, ensuring coroutines resume on the correct executor.

Thread Safety

Distinct objects: Safe. Shared objects: Unsafe. A timer must not have concurrent wait operations.

Semantics

Wraps platform timer facilities via the io_context reactor. Operations dispatch to OS timer APIs (timerfd, IOCP timers, kqueue EVFILT_TIMER).

Base Classes

Name Description

io_object

Base class for platform I/O objects.

Types

Name

Description

handle

RAII wrapper for I/O object implementation lifetime.

implementation

Forward declaration for platform‐specific implementation.

io_object_impl

Base interface for platform I/O implementations.

io_service

Service interface for I/O object lifecycle management.

timer_impl

clock_type

The clock type used for time operations.

duration

The duration type for relative expiry times.

time_point

The time point type for absolute expiry times.

Member Functions

Name

Description

timer [constructor] [deleted]

Constructors

~timer [destructor] [virtual]

Destructor.

operator= [deleted]

Move assignment operator.

cancel

Cancel any pending asynchronous operations.

context

Return the execution context.

expires_after

Set the timer's expiry time relative to now.

expires_at

Set the timer's expiry time as an absolute time.

expiry

Get the timer's expiry time as an absolute time.

wait

Wait for the timer to expire.

Protected Data Members

Name

ctx_

impl_

Created with MrDocs