Public Member Functions | Private Member Functions | Private Attributes

ana_multiple_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_multiple_receive_handler:
Inheritance graph
[legend]
Collaboration diagram for ana_multiple_receive_handler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ana_multiple_receive_handler (ana_component_set &components)
 Constructs a reader handler object.
 ~ana_multiple_receive_handler ()
 Destructor.
void wait_completion (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.
ana::read_buffer buffer () const
 Returns the buffer from the operation.
network::connection get_wesnoth_id () const

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_setcomponents_
boost::mutex mutex_
boost::mutex handler_mutex_
boost::mutex timeout_called_mutex_
ana::error_code error_code_
ana::read_buffer buffer_
network::connection wesnoth_id_
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 270 of file network_manager_ana.hpp.


Constructor & Destructor Documentation

ana_multiple_receive_handler::ana_multiple_receive_handler ( ana_component_set components  ) 

Constructs a reader handler object.

Definition at line 197 of file network_manager_ana.cpp.

References components_, mutex_, and timeout_called_mutex_.

ana_multiple_receive_handler::~ana_multiple_receive_handler (  ) 

Destructor.

Definition at line 224 of file network_manager_ana.cpp.

References handler_mutex_, and timeout_called_mutex_.


Member Function Documentation

ana::read_buffer ana_multiple_receive_handler::buffer (  )  const [inline]

Returns the buffer from the operation.

Definition at line 301 of file network_manager_ana.hpp.

References buffer_.

Referenced by ana_network_manager::read_from().

Here is the caller graph for this function:

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

Returns the error_code from the operation.

Definition at line 295 of file network_manager_ana.hpp.

References error_code_.

Referenced by ana_network_manager::read_from().

Here is the caller graph for this function:

network::connection ana_multiple_receive_handler::get_wesnoth_id (  )  const [inline]

Definition at line 306 of file network_manager_ana.hpp.

References wesnoth_id_.

Referenced by ana_network_manager::read_from().

Here is the caller graph for this function:

void ana_multiple_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 295 of file network_manager_ana.cpp.

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

void ana_multiple_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 266 of file network_manager_ana.cpp.

References buffer_, components_, error_code_, finished_, ana_component::get_id(), handler_mutex_, mutex_, receive_timer_, and wesnoth_id_.

Here is the call graph for this function:

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

Definition at line 310 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_multiple_receive_handler::wait_completion ( 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 232 of file network_manager_ana.cpp.

References components_, 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 323 of file network_manager_ana.hpp.

Referenced by buffer(), and handle_receive().

Definition at line 322 of file network_manager_ana.hpp.

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

boost::mutex ana_multiple_receive_handler::mutex_ [private]

Definition at line 324 of file network_manager_ana.hpp.

Referenced by get_wesnoth_id(), and handle_receive().


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