Messageable Class Reference

The interface for any type of connection that can accept messages. More...

#include <messageable.h>

Inheritance diagram for Messageable:

Inheritance graph
[legend]
Collaboration diagram for Messageable:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Messageable ()
virtual ~Messageable ()
void queue_message (MessageP &)
 enqueue a message for this Messageable
virtual std::string get_id (void) const =0

Protected Member Functions

MessageP get_message (void)
 Request a Message be dequeued and returned.
Datahandle_message (MessageP &)
 Handle messages being sent to us.

Private Types

typedef std::deque< MessageP >
::iterator 
queue_iterator
 iterator typedef

Private Attributes

std::deque< MessagePmsg_queue
 The queue of messages to be handled by this object.
pthread_mutex_t msg_mutex
 The mutex for the deque.
pthread_cond_t msg_avail
 condition variable for new data on the queue


Detailed Description

The interface for any type of connection that can accept messages.

Definition at line 15 of file messageable.h.


Member Typedef Documentation

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

iterator typedef

Reimplemented in Outlet.

Definition at line 50 of file messageable.h.


Constructor & Destructor Documentation

Messageable::Messageable ( void   ) 

Definition at line 11 of file messageable.cc.

References msg_avail, msg_mutex, and PTHREAD_CHECK_AND_THROW.

Messageable::~Messageable ( void   )  [virtual]

Todo:
I need to figure out a way that I can ensure, upon destruction of a Messageable, that noone will ever try to send messages to us. They could still have a pointer to us, and that would be bad.

Definition at line 24 of file messageable.cc.

References msg_avail, and msg_mutex.


Member Function Documentation

void Messageable::queue_message ( MessageP msg  ) 

enqueue a message for this Messageable

Queue a Message object to be processed/handled by this Messageable.

Put the MessageP in our queue, then tag the condition variable to wake anyone waiting on it...

Definition at line 47 of file messageable.cc.

References get_id(), msg_avail, msg_mutex, msg_queue, and PTHREAD_CHECK_AND_THROW.

Referenced by MasterController::handle_signals(), Connection::note_disconnect(), and Connection::shutdown().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual std::string Messageable::get_id ( void   )  const [pure virtual]

Implemented in BiDirConn, Connection, Incoming, MasterController, and Outlet.

Referenced by queue_message().

Here is the caller graph for this function:

MessageP Messageable::get_message ( void   )  [protected]

Request a Message be dequeued and returned.

Wait on the condition variable for a message to appear.

This method will block on msg_avail until it can dequeue and return a MessageP.

This uses the msg_avail pthread condition variable to wait for a Message object to be available. It will block until able to return a Message object.

Definition at line 70 of file messageable.cc.

References msg_avail, msg_mutex, msg_queue, and PTHREAD_CHECK_AND_THROW.

Referenced by MasterController::manage_connections(), and Connection::manager().

Here is the caller graph for this function:

Data * Messageable::handle_message ( MessageP msg  )  [protected]

Handle messages being sent to us.

Return a Data* of data if we have data to be written (to ourself), or NULL to indicate that no data is to be written.

Todo:
Need to modify this function to operate the way we expect it to. Will it get data? Where does it need to send it? Since we're not in Outlet anymore, we can't just assume it's for us.

Definition at line 100 of file messageable.cc.

References Message::C_Exit, Message::M_Command, MUTEX_LOG, Message::name(), and Connection::shutdown().

Referenced by Connection::manager().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

std::deque<MessageP> Messageable::msg_queue [private]

The queue of messages to be handled by this object.

Definition at line 44 of file messageable.h.

Referenced by get_message(), and queue_message().

pthread_mutex_t Messageable::msg_mutex [private]

The mutex for the deque.

See also:
msg_queue

Definition at line 46 of file messageable.h.

Referenced by get_message(), Messageable(), queue_message(), and ~Messageable().

pthread_cond_t Messageable::msg_avail [private]

condition variable for new data on the queue

See also:
msg_queue

Definition at line 48 of file messageable.h.

Referenced by get_message(), Messageable(), queue_message(), and ~Messageable().


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

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