Public Member Functions | Private Member Functions | Private Attributes

ana::timer Class Reference

General purpose asynchronous timer. More...

#include <timers.hpp>

List of all members.

Public Member Functions

 timer ()
 Standard constructor.
 timer (boost::asio::io_service &io)
 Construct a timer object using a running io_service object.
template<class Handler >
void wait (size_t milliseconds, Handler handler)
 Wait in background a given amount of milliseconds.
 ~timer ()
 Standard destructor, cancels pending operations if handler wasn't called.

Private Member Functions

void run ()

Private Attributes

const bool holds_fresh_io_service_
boost::asio::io_service * io_service_
boost::thread * timer_thread_
boost_timer timer_

Detailed Description

General purpose asynchronous timer.

Definition at line 164 of file timers.hpp.


Constructor & Destructor Documentation

ana::timer::timer (  ) 

Standard constructor.

Creates its own io_service object and runs in its own thread.

Definition at line 75 of file asio_timers.cpp.

ana::timer::timer ( boost::asio::io_service &  io  ) 

Construct a timer object using a running io_service object.

The timer insures it won't stop the io_service.

Precondition:
The io_service will be running during the timer's lifetime.

Definition at line 83 of file asio_timers.cpp.

ana::timer::~timer (  ) 

Standard destructor, cancels pending operations if handler wasn't called.

Definition at line 91 of file asio_timers.cpp.

References holds_fresh_io_service_, io_service_, and timer_thread_.


Member Function Documentation

void ana::timer::run (  )  [private]

Definition at line 101 of file asio_timers.cpp.

References holds_fresh_io_service_, and io_service_.

Referenced by wait().

Here is the caller graph for this function:

template<class Handler >
void ana::timer::wait ( size_t  milliseconds,
Handler  handler 
) [inline]

Wait in background a given amount of milliseconds.

The method shouldn't be called with a size_t constant directly. Instead, the user should use the functions in the ana::time namespace.

Parameters:
milliseconds : Amount of milliseconds to wait.
handler : Handler object to handle the timeout event.

Examples:

  • wait( ana::time::seconds(5), boost::bind( &ChatServer::handle_timeout, this, boost::asio::placeholders::error);
See also:
ana::time

Definition at line 199 of file timers.hpp.

References holds_fresh_io_service_, run(), timer_, and timer_thread_.

Referenced by asio_client::start_connection_timer(), ana::detail::timed_sender::start_timer(), ana_multiple_receive_handler::wait_completion(), ana_receive_handler::wait_completion(), and asio_listener::wait_for_incoming_message().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 215 of file timers.hpp.

Referenced by run(), wait(), and ~timer().

boost::asio::io_service* ana::timer::io_service_ [private]

Definition at line 217 of file timers.hpp.

Referenced by run(), and ~timer().

Definition at line 221 of file timers.hpp.

Referenced by wait().

boost::thread* ana::timer::timer_thread_ [private]

Definition at line 219 of file timers.hpp.

Referenced by wait(), and ~timer().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:19:18 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs