#include <incoming.h>
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. |
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.
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.
Definition at line 65 of file incoming.cc.
References start_listening().
Incoming::~Incoming | ( | ) |
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().
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().
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().
ListenerP Incoming::base [private] |
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().
ConnEventHandler Incoming::handler [private] |
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().