#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.
Member Function Documentation
|
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. |
|
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