Public Member Functions | Private Member Functions | Private Attributes

ana_receive_handler Class Reference

To use the asynchronous library synchronously, objects of this type lock a mutex until enough calls have been made to the associated handler. More...

#include <network_manager_ana.hpp>

Inheritance diagram for ana_receive_handler:
Inheritance graph
[legend]
Collaboration diagram for ana_receive_handler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ana_receive_handler (ana_component_set::iterator)
 Constructs a reader handler object.
 ~ana_receive_handler ()
 Destructor.
void wait_completion (ana::detail::timed_sender *component, size_t timeout_ms=0)
 Attempts to read from those network components associated with this handler object up until timeout_ms milliseconds.
const ana::error_codeerror () const
 Returns the error_code from the operation.

Private Member Functions

virtual void handle_receive (ana::error_code, ana::net_id, ana::read_buffer)
 Handle an incoming message event.
virtual void handle_disconnect (ana::error_code, ana::net_id)
 Handle a disconnect event.
void handle_timeout (ana::error_code error_code)

Private Attributes

ana_component_set::iterator iterator_
boost::mutex mutex_
boost::mutex handler_mutex_
boost::mutex timeout_called_mutex_
ana::error_code error_code_
ana::timerreceive_timer_
bool finished_

Detailed Description

To use the asynchronous library synchronously, objects of this type lock a mutex until enough calls have been made to the associated handler.

Definition at line 219 of file network_manager_ana.hpp.


Constructor & Destructor Documentation

ana_receive_handler::ana_receive_handler ( ana_component_set::iterator  iterator  ) 

Constructs a reader handler object.

Definition at line 96 of file network_manager_ana.cpp.

References mutex_, and timeout_called_mutex_.

ana_receive_handler::~ana_receive_handler (  ) 

Destructor.

Definition at line 109 of file network_manager_ana.cpp.

References handler_mutex_, and timeout_called_mutex_.


Member Function Documentation

const ana::error_code& ana_receive_handler::error (  )  const [inline]

Returns the error_code from the operation.

Definition at line 244 of file network_manager_ana.hpp.

References error_code_.

Referenced by ana_network_manager::read_from().

Here is the caller graph for this function:

void ana_receive_handler::handle_disconnect ( ana::error_code  ,
ana::net_id   
) [private, virtual]

Handle a disconnect event.

Parameters:
error_code : Error code of the disconnecting client, it could shed some light into why it got disconnected.
net_id : ID of the client that gets disconnected.
See also:
error_code
net_id

Implements ana::listener_handler.

Definition at line 161 of file network_manager_ana.cpp.

References error_code_, finished_, handler_mutex_, mutex_, and receive_timer_.

void ana_receive_handler::handle_receive ( ana::error_code  ,
ana::net_id  ,
ana::read_buffer   
) [private, virtual]

Handle an incoming message event.

Parameters:
error_code : Error code of the client sending the message, if it evaluates to false, then no error occurred.
net_id : ID of the client that sends the message.
shared_buffer : The buffer from the incoming message.
See also:
read_buffer
error_code
net_id

Implements ana::listener_handler.

Definition at line 141 of file network_manager_ana.cpp.

References error_code_, finished_, handler_mutex_, mutex_, and receive_timer_.

void ana_receive_handler::handle_timeout ( ana::error_code  error_code  )  [private]

Definition at line 177 of file network_manager_ana.cpp.

References error_code_, finished_, handler_mutex_, mutex_, receive_timer_, and timeout_called_mutex_.

Referenced by wait_completion().

Here is the caller graph for this function:

void ana_receive_handler::wait_completion ( ana::detail::timed_sender component,
size_t  timeout_ms = 0 
)

Attempts to read from those network components associated with this handler object up until timeout_ms milliseconds.

If the timeout parameter is 0, it will lock the current thread until one of these components has received a message.

Parameters:
component : A network component running an io_service which supports timeout capabilities.
timeout_ms : Amount of milliseconds to timeout the operation.

Definition at line 117 of file network_manager_ana.cpp.

References ana::detail::timed_sender::create_timer(), finished_, handle_timeout(), handler_mutex_, ana::time::milliseconds(), mutex_, receive_timer_, timeout_called_mutex_, ana::timeout_error, and ana::timer::wait().

Referenced by ana_network_manager::read_from().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 260 of file network_manager_ana.hpp.

Referenced by error(), handle_disconnect(), handle_receive(), and handle_timeout().

boost::mutex ana_receive_handler::handler_mutex_ [private]
ana_component_set::iterator ana_receive_handler::iterator_ [private]

Definition at line 255 of file network_manager_ana.hpp.

boost::mutex ana_receive_handler::mutex_ [private]

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:12:48 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs