Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Mailbox Class Reference
[Communications Facilities]

#include <Mailbox.hh>

List of all members.


Detailed Description

Class for receiving messages from remote mailers.

Mailbox is a class for receiving messages from remote mailers. Mail is the most primitive form of communications in RHexLib. A send to a mailbox results in an immediate dispatch of a UDP message. There is no guarantee that this message will get through, and no guarantee that later messages will not be received first. The receiver mailbox simply has an indicator of whether new mail has been received or not. The user can examine the mailbox's current contents, which reflects only the last mail received: any older messages are overwritten. Mailboxes take incoming messages without queueing them. Whatever has come in latest is what is presented to the applications.

Applications use getData to get the current content of the mailbox. Applications must use releaseMsg to release the message memory back to the mailbox. If applications so desire, they could just delete the memory themselves, but in the standard case of getData/releaseMsg pairs, there will be no frees or mallocs after the second getData, otherwise the class will continually be allocating new messages.


Public Member Functions

 Mailbox (int size, com_id_t mailbox_id, com_id_t exclusive_client=0)
MessagewaitData (unsigned int msecs_timeout)
MessagegetData ()
void releaseMsg (Message *)
bool newMail () const
int getMaxSize () const
com_id_t getID () const
int getInt ()
double getDouble ()
com_id_t exclusiveClient () const
void processMsg (RemoteManager *dest, TimeStamp receipt_time, Byte *buf, int len)


Member Function Documentation

Message* Mailbox::getData  ) 
 

This method returns the current data in the mail box.

double Mailbox::getDouble  ) 
 

This method is a convenience function for if the mailbox just contains a double precision floating point number. Note: mailboxes are not free, if you have a large number of associated values it is much better to group them as a single mailbox containing a structure rather than a group of mailboxes with integers and doubles, despite the ``ease of use'' of integer and double access. Grouping into one mailbox saves overhead on the communications manager, as well as guaranteeing simultenaity of the grouped data.

com_id_t Mailbox::getID  )  const [inline]
 

This method returns the mailbox identifier.

int Mailbox::getInt  ) 
 

This method is a convenience function for if the mailbox just contains an integer. Note: mailboxes are not free, if you have a large number of associated values it is much better to group them as a single mailbox containing a structure rather than a group of mailboxes with integers and doubles, despite the ``ease of use'' of integer and double access. Grouping into one mailbox saves overhead on the communications manager, as well as guaranteeing simultenaity of the grouped data.

int Mailbox::getMaxSize  )  const [inline]
 

This method returns the mailbox capacity in bytes.

bool Mailbox::newMail  )  const [inline]
 

This method returns true if a mail message has arrived since the last invocation of getData.

void Mailbox::releaseMsg Message  ) 
 

After you are through with the message returned by getData, you must release it back to the mailbox through this method. If you do this religiously, then you will make mailbox operations vastly more efficient, reducing the number of memory copies, allocations, and deallocations to a bare minimum.


RHexLib Reference Documentation