#include <outlet.h>
Public Member Functions | |
Outlet (ConnectorP &) | |
Constructor and destructor. | |
virtual | ~Outlet () throw () |
void | queue_data (MessageP &) |
Queue data for this outlet... | |
void | add_decoder (Decoder *) |
Push a protocol-manager (Decoder) onto the set of decoders. | |
virtual std::string | class_name (void) const |
Sub-class identification strings (abstract virtual). | |
virtual std::string | get_id (void) const |
Protected Member Functions | |
void | start_engine (void) |
Invoke the writer thread with pthread_create(), and return. | |
virtual void | stop_engine (void) |
Shutdown and detach the writer thread... | |
Private Types | |
typedef std::deque< MessageP > ::iterator | queue_iterator |
iterator typedef | |
Private Member Functions | |
void | writer (void) |
The core of the writer thread. | |
void | write_data () |
Static Private Member Functions | |
static void * | writer_thread (void *) |
Wrapper function to call the private thread function of the same root name. | |
Private Attributes | |
pthread_t | tid_writer |
The pthread_t id of the writer thread... | |
std::deque< MessageP > | data |
The queue of things to be written to this outlet. | |
pthread_mutex_t | data_mutex |
the mutex for the deque (data) | |
pthread_cond_t | data_avail |
condition variable signalling new data on the queue (data) |
Definition at line 70 of file outlet.h.
typedef std::deque<MessageP>::iterator Outlet::queue_iterator [private] |
Outlet::Outlet | ( | ConnectorP & | ourConnector | ) |
Constructor and destructor.
Definition at line 100 of file outlet.cc.
References data_avail, data_mutex, DMUTEX_LOG, and PTHREAD_CHECK_AND_THROW.
Outlet::~Outlet | ( | void | ) | throw () [virtual] |
Definition at line 121 of file outlet.cc.
References data_mutex, DMUTEX_LOG, Connection::mutex, mutex_info(), MUTEX_LOG, and PTHREAD_CHECK_AND_THROW.
void Outlet::queue_data | ( | MessageP & | dmsg | ) |
Queue data for this outlet...
Queue data to be written out to this outlet.
This method is invoked by the Connection that has the data to be written, rather than being invoked from within this object.
clog << "Message type " << dmsg->name() << " is " << dmsg->len() << " bytes long" << endl;
will lock forever, as the first opertor-> will lock the MessageP, and when the second invocation of operator-> tries to lock the object, it will hang. Definition at line 371 of file outlet.cc.
References data, data_avail, data_mutex, get_id(), and PTHREAD_CHECK_AND_THROW.
Referenced by invoke_queue_data::operator()().
virtual std::string Outlet::class_name | ( | void | ) | const [inline, virtual] |
Sub-class identification strings (abstract virtual).
Reimplemented from Connection.
Reimplemented in BiDirConn.
Definition at line 82 of file outlet.h.
Referenced by get_id().
std::string Outlet::get_id | ( | void | ) | const [virtual] |
Implements Connection.
Reimplemented in BiDirConn.
Definition at line 329 of file outlet.cc.
References Connection::base, and class_name().
Referenced by ConnectionList::mutexed_for_each(), queue_data(), stop_engine(), and writer().
void Outlet::start_engine | ( | void | ) | [protected, virtual] |
Invoke the writer thread with pthread_create(), and return.
Implements Connection.
Reimplemented in BiDirConn.
Definition at line 317 of file outlet.cc.
References PTHREAD_CHECK_AND_THROW, tid_writer, and writer_thread().
Referenced by BiDirConn::start_engine().
void * Outlet::writer_thread | ( | void * | instance | ) | [static, private] |
Wrapper function to call the private thread function of the same root name.
Since it's a static function, it can be passed as a pointer to pthread_create(), whereas the method below can't...
Definition at line 68 of file outlet.cc.
References fireball::bail(), pthread_exception::what(), and writer().
Referenced by start_engine().
void Outlet::writer | ( | void | ) | [private] |
The core of the writer thread.
Definition at line 174 of file outlet.cc.
References data, data_avail, data_mutex, DMUTEX_LOG, get_id(), Connection::please_exit, PTHREAD_CHECK_AND_THROW, and write_data().
Referenced by writer_thread().
void Outlet::write_data | ( | ) | [private] |
Definition at line 222 of file outlet.cc.
References Connection::base, data, data_mutex, DMUTEX_LOG, Connection::note_disconnect(), PTHREAD_CHECK_AND_THROW, and stop_engine().
Referenced by writer().
void Outlet::stop_engine | ( | void | ) | [protected, virtual] |
Shutdown and detach the writer thread...
Implements Connection.
Reimplemented in BiDirConn.
Definition at line 282 of file outlet.cc.
References get_id(), PTHREAD_CHECK_AND_THROW, and tid_writer.
Referenced by BiDirConn::stop_engine(), and write_data().
pthread_t Outlet::tid_writer [private] |
The pthread_t id of the writer thread...
Definition at line 113 of file outlet.h.
Referenced by start_engine(), and stop_engine().
std::deque<MessageP> Outlet::data [private] |
The queue of things to be written to this outlet.
Definition at line 125 of file outlet.h.
Referenced by queue_data(), write_data(), and writer().
pthread_mutex_t Outlet::data_mutex [private] |
the mutex for the deque (data)
Definition at line 127 of file outlet.h.
Referenced by Outlet(), queue_data(), write_data(), writer(), and ~Outlet().
pthread_cond_t Outlet::data_avail [private] |