Incoming Class Reference

A class using a Listener on which to listen for incoming connections. More...

#include <incoming.h>

Inheritance diagram for Incoming:

Inheritance graph
[legend]
Collaboration diagram for Incoming:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Incoming (ListenerP l, ConnEventHandler ceh)
 Construct the Incoming object.
 ~Incoming ()
std::string get_id (void) const

Private Member Functions

void start_listening ()
 Start listening. This will start up the listener_thread(), and return.

Static Private Member Functions

static void * listener_thread (void *)
 The thread-head function for listening for connections...

Private Attributes

ListenerP base
 The base Listener that we're going start listening on...
ConnEventHandler handler
 The ConnEventHandler that should be called for each received connection.
pthread_t tid_listener
 The listener thread.


Detailed Description

A class using a Listener on which to listen for incoming connections.

This class is a protected subclass of Messageable because MasterController needs to be able to put us on its list of children, which is implemented as a list of Messageable* at the moment.

Definition at line 91 of file incoming.h.


Constructor & Destructor Documentation

Incoming::Incoming ( ListenerP  l,
ConnEventHandler  ceh 
)

Construct the Incoming object.

Take the Listener object who will be listening for and accepting incoming connectors, then construct a Connection (currently BiDirConn) and call the ConnEventHandler object to cross-connect the new Connection to anything else it needs to be connected to. This constructor calls start_listening() which invokes a thread to do all of the underlying work.

Note:
It's safe to start a thread from this constructor only because this is not a virtual object, so incomplete construction, while technically still possible, is unlikely to become a problem. Is it possible to delay the start of the thread until after this constructor terminates?

Definition at line 65 of file incoming.cc.

References start_listening().

Here is the call graph for this function:

Incoming::~Incoming (  ) 

Definition at line 71 of file incoming.cc.

References PTHREAD_CHECK_AND_THROW, and tid_listener.


Member Function Documentation

std::string Incoming::get_id ( void   )  const [virtual]

Implements Messageable.

Definition at line 192 of file incoming.cc.

References base.

Referenced by MasterController::start_connections().

Here is the caller graph for this function:

void Incoming::start_listening ( void   )  [private]

Start listening. This will start up the listener_thread(), and return.

This method will start the listening process.

Incoming::listener_thread() will be invoked via pthread_create(), the pthread_t will be stored, and we then return.

Definition at line 108 of file incoming.cc.

References listener_thread(), PTHREAD_CHECK_AND_THROW, and tid_listener.

Referenced by Incoming().

Here is the call graph for this function:

Here is the caller graph for this function:

void * Incoming::listener_thread ( void *  instance  )  [static, private]

The thread-head function for listening for connections...

This thread start routine will take this object as a parameter, and tell the base/underlying Listener object to listen for a new connection.

When a connection is accepted, the Listener will return a new Connector, and we'll construct a Connection (currently BiDirConn) which will cause management (and start a reader & writer). We'll then call the underlying Listener::listen_for_incoming() method again to wait for a new connection. Repeat ad-nauseum.

Connection needs a way to be instantiated with a Connector that's already connected. That Connection is then constructed here. But, who keeps track of managing it for messaging purposes? The Messageable mixin probably needs its own thread for this purpose.

Definition at line 126 of file incoming.cc.

References Messager::add_recipient(), fireball::bail(), base, CATCH_OR_DIE, MasterController::get_instance(), handler, and pthread_exception::what().

Referenced by start_listening().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

The base Listener that we're going start listening on...

Definition at line 107 of file incoming.h.

Referenced by get_id(), and listener_thread().

The ConnEventHandler that should be called for each received connection.

Definition at line 109 of file incoming.h.

Referenced by listener_thread().

pthread_t Incoming::tid_listener [private]

The listener thread.

Definition at line 112 of file incoming.h.

Referenced by start_listening(), and ~Incoming().


The documentation for this class was generated from the following files:

Generated on Tue May 13 11:32:47 2008 for consmgr by  doxygen 1.5.5