Outlet Class Reference
[Connection implementation classes and data]

Provides the interface to output data on a connection. More...

#include <outlet.h>

Inheritance diagram for Outlet:

Inheritance graph
[legend]
Collaboration diagram for Outlet:

Collaboration graph
[legend]

List of all members.

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< MessagePdata
 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)


Detailed Description

Provides the interface to output data on a connection.

Definition at line 70 of file outlet.h.


Member Typedef Documentation

typedef std::deque<MessageP>::iterator Outlet::queue_iterator [private]

iterator typedef

Reimplemented from Messageable.

Definition at line 131 of file outlet.h.


Constructor & Destructor Documentation

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.

Here is the call graph for this function:


Member Function Documentation

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.

Note:
It's critical that you DO NOT dereference this MessageP more than once in an individual line. For example: 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()().

Here is the call graph for this function:

Here is the caller graph for this function:

void Outlet::add_decoder ( Decoder  ) 

Push a protocol-manager (Decoder) onto the set of decoders.

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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]

condition variable signalling new data on the queue (data)

Definition at line 129 of file outlet.h.

Referenced by Outlet(), queue_data(), and writer().


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

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