asio 0.1.5 Main Page | Class Index | Member Index | Tutorial

basic_timer Class Template Reference

The basic_timer class template provides asynchronous timer functionality. Most applications will use the timer typedef. More...

Inheritance diagram for basic_timer:

Inheritance graph
Collaboration diagram for basic_timer:

Collaboration graph
List of all members.

Public Types

typedef Service service_type
 The type of the service that will be used to provide timer operations.

typedef service_type::impl_type impl_type
 The native implementation type of the timer.

typedef service_type::demuxer_type demuxer_type
 The demuxer type for this asynchronous type.


Public Member Functions

 basic_timer (demuxer_type &d)
 Constructor.

 basic_timer (demuxer_type &d, from_type from_when, long seconds, long microseconds=0)
 Constructor to set a particular expiry time.

 ~basic_timer ()
 Destructor.

demuxer_typedemuxer ()
 Get the demuxer associated with the asynchronous object.

impl_type impl ()
 Get the underlying implementation in the native type.

void set (from_type from_when, long seconds, long microseconds=0)
 Set the timer.

void expire ()
 Expire the timer immediately.

void wait ()
 Perform a blocking wait on the timer.

template<typename Handler> void async_wait (Handler handler)
 Start an asynchronous wait on the timer.

template<typename Handler, typename Completion_Context> void async_wait (Handler handler, Completion_Context context)
 Start an asynchronous wait on the timer.


Private Attributes

service_typeservice_
 The backend service implementation.

impl_type impl_
 The underlying native implementation.


Detailed Description

template<typename Service>
class asio::basic_timer< Service >

The basic_timer class template provides asynchronous timer functionality. Most applications will use the timer typedef.


Member Typedef Documentation

typedef Service service_type
 

The type of the service that will be used to provide timer operations.

typedef service_type::impl_type impl_type
 

The native implementation type of the timer.

typedef service_type::demuxer_type demuxer_type
 

The demuxer type for this asynchronous type.


Constructor & Destructor Documentation

basic_timer demuxer_type d  )  [explicit]
 

Constructor.

This constructor creates a timer without setting an expiry time. The set() function must be called before the timer can be waited on.

Parameters:
d The demuxer object that the timer will use to deliver completions for any asynchronous operations performed on the timer.

basic_timer demuxer_type d,
from_type  from_when,
long  seconds,
long  microseconds = 0
 

Constructor to set a particular expiry time.

This constructor creates a timer and sets the expiry time.

Parameters:
d The demuxer object that the timer will use to deliver completions for any asynchronous operations performed on the timer.
from_when The origin time against which the seconds and microseconds values are measured.
seconds The number of seconds after the from_when origin that the time should expire.
microseconds The number of microseconds which, in addition to the seconds value, is used to calculate the expiry time relative to the from_when origin value.

~basic_timer  ) 
 

Destructor.


Member Function Documentation

demuxer_type& demuxer  ) 
 

Get the demuxer associated with the asynchronous object.

This function may be used to obtain the demuxer object that the timer uses to deliver completions for asynchronous operations.

Returns:
A reference to the demuxer object that the timer will use to deliver completion notifications. Ownership is not transferred to the caller.

impl_type impl  ) 
 

Get the underlying implementation in the native type.

This function may be used to obtain the underlying implementation of the timer. This is intended to allow access to native timer functionality that is not otherwise provided.

void set from_type  from_when,
long  seconds,
long  microseconds = 0
 

Set the timer.

This function sets the expiry time.

Parameters:
from_when The origin time against which the seconds and microseconds values are measured.
seconds The number of seconds after the from_when origin that the time should expire.
microseconds The number of microseconds which, in addition to the seconds value, is used to calculate the expiry time relative to the from_when origin value.

void expire  ) 
 

Expire the timer immediately.

This function causes the timer to expire immediately. If there is a pending asynchronous wait operation against the timer it will be forced to complete.

void wait  ) 
 

Perform a blocking wait on the timer.

This function is used to wait for the timer to expire. This function blocks and does not return until the timer has expired.

void async_wait Handler  handler  ) 
 

Start an asynchronous wait on the timer.

This function may be used to initiate an asynchronous wait against the timer. It always returns immediately, but the specified handler will be notified when the timer expires.

Parameters:
handler The completion handler to be called when the timer expires. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void handler(); 

void async_wait Handler  handler,
Completion_Context  context
 

Start an asynchronous wait on the timer.

This function may be used to initiate an asynchronous wait against the timer. It always returns immediately, but the specified handler will be notified when the timer expires.

Parameters:
handler The completion handler to be called when the timer expires. Copies will be made of the handler as required. The equivalent function signature of the handler must be:
 void handler(); 
context The completion context which controls the number of concurrent invocations of handlers that may be made. Copies will be made of the context object as required, however all copies are equivalent.


Member Data Documentation

service_type& service_ [private]
 

The backend service implementation.

impl_type impl_ [private]
 

The underlying native implementation.