#include <Message.h>
Collaboration diagram for vpr::sim::Message:

Public Types | |
| typedef std::vector< vpr::Uint8 > | MessageDataType |
| typedef boost::shared_ptr< std::vector< vpr::Uint8 > > | MessageDataPtr |
Public Methods | |
| Message (const void *msg, const vpr::Uint32 msg_size) | |
| Creates a new message by copying the given buffer into freshly allocated memory. More... | |
| Message (MessageDataPtr msgData) | |
| Creates message by copying shared pointer to data buffer. More... | |
| Message (const Message &msg) | |
| Copy constructor that makes a copy of the given source object. More... | |
| ~Message () | |
| Releases the memory allocated for the contained message body. More... | |
| void | setStartOnWireTime (const vpr::Interval &time) |
| const vpr::Interval & | whenStartOnWire () const |
| void | setFullyOnWireTime (const vpr::Interval &time) |
| const vpr::Interval & | whenFullyOnWire () const |
| void | setArrivesFullyTime (const vpr::Interval &time) |
| const vpr::Interval & | whenArrivesFully () const |
| void * | getBody () const |
| MessageDataPtr | getMessageData () |
| vpr::Uint32 | getSize () const |
| vpr::Uint32 | resize (const vpr::Uint32 bytes_read) |
| Determines if this message needs to be resized after a read. More... | |
| void | setPath (NetworkGraph::VertexListPtr path, const vpr::SocketImplSIM *source, vpr::SocketImplSIM *dest) |
| Assigns the path that this message will follow. More... | |
| const NetworkGraph::VertexListPtr & | getPath () const |
| Returns a constant reference to the path that this message will follow. More... | |
| const vpr::SocketImplSIM * | getSourceSocket () const |
| vpr::SocketImplSIM * | getDestinationSocket () const |
| const NetworkGraph::net_vertex_t & | getNextHop () const |
| Retrieves the next hop (network graph vertex) in the path of this message and returns it to the caller via the by-reference parameter. More... | |
| void | incNextHop (bool &end_of_path) |
| Increment the pointer to the next hop in this message's path as it moves towards its destination. More... | |
Copying these objects is an expensive operation, and hence, it should be done as infrequently as possible. Passing by reference may require access synchronization, however.
Definition at line 73 of file Message.h.
|
|
|
|
|
|
|
||||||||||||
|
Creates a new message by copying the given buffer into freshly allocated memory.
Definition at line 83 of file Message.h.
00084 : mSrcSock(NULL), mDestSock(NULL)
00085 {
00086 vpr::Uint8* start = (vpr::Uint8*) msg;
00087 mMsg = MessageDataPtr( new MessageDataType(start, start+msg_size));
00088 //mMsg = malloc(msg_size);
00089 //memcpy(mMsg, msg, msg_size);
00090 }
|
|
|
Creates message by copying shared pointer to data buffer.
Definition at line 93 of file Message.h.
00094 : mSrcSock(NULL), mDestSock(NULL)
00095 {
00096 mMsg = msgData;
00097 }
|
|
|
Copy constructor that makes a copy of the given source object. That is, now new memory is allocated for this object's copy of the message body, instead we just make a copy of the shared_ptr to the message body and share it with the other message Definition at line 54 of file Message.cpp. References vprASSERT.
00055 : mStartOnWire(msg.mStartOnWire),
00056 mFullyOnWire(msg.mFullyOnWire), mArrivesFully(msg.mArrivesFully),
00057 mMsgPath(msg.mMsgPath), mNextHop(msg.mNextHop), mSrcSock(msg.mSrcSock),
00058 mDestSock(msg.mDestSock)
00059 {
00060 vprASSERT(false && "In copy constructor");
00061 mMsg = msg.mMsg; // Just copy the shared pointer. VERY cheap
00062
00063 /*
00064 if ( (msg.mMsg.get() != NULL) && (!msg.mMsg->empty()) )
00065 {
00066 // Yikes, this could get expensive!
00067 // XXX: Find out if this is REALLY needed
00068 mMsg = MessageDataPtr( new MessageDataType(msg.mMsg->begin(), msg.mMsg->end()));
00069 //mMsg = malloc(msg.mMsgSize);
00070 //memcpy(mMsg, msg.mMsg, msg.mMsgSize);
00071 }
00072 */
00073 }
|
|
|
Releases the memory allocated for the contained message body.
Definition at line 110 of file Message.h.
00111 {
00112 // Releases automatically based on shared_ptr semantics
00113 }
|
|
|
Definition at line 115 of file Message.h.
00116 {
00117 mStartOnWire = time;
00118 }
|
|
|
Definition at line 120 of file Message.h.
00121 {
00122 return mStartOnWire;
00123 }
|
|
|
Definition at line 125 of file Message.h.
00126 {
00127 mFullyOnWire = time;
00128 }
|
|
|
Definition at line 130 of file Message.h.
00131 {
00132 return mFullyOnWire;
00133 }
|
|
|
Definition at line 135 of file Message.h.
00136 {
00137 mArrivesFully = time;
00138 }
|
|
|
Definition at line 140 of file Message.h.
00141 {
00142 return mArrivesFully;
00143 }
|
|
|
Definition at line 145 of file Message.h.
00146 {
00147 return (void*)&((*mMsg)[0]);
00148 }
|
|
|
Definition at line 151 of file Message.h.
00152 {
00153 return mMsg;
00154 }
|
|
|
Definition at line 156 of file Message.h. Referenced by resize.
00157 {
00158 return mMsg->size();
00159 }
|
|
|
Determines if this message needs to be resized after a read. If the given number of bytes read from the message is less than the actual size, this message is resized to contain only the remaining unread bytes.
Definition at line 75 of file Message.cpp. References getSize, and vprASSERT.
00076 {
00077 vpr::Uint32 resize_amount;
00078
00079 resize_amount = getSize() - bytes_read;
00080
00081 // Only resize the message if 0 < bytes_read < mMessageSize.
00082 if ( resize_amount > 0 && resize_amount != getSize() ) {
00083
00084 mMsg->erase(mMsg->begin(), mMsg->begin()+bytes_read);
00085 vprASSERT(resize_amount == mMsg->size()); // Must be this size
00086
00087 /*
00088 char* data;
00089 vpr::Uint32 i;
00090
00091 data = (char*) mMsg;
00092
00093 // If there is still stuff left in the buffer, move it over.
00094 for ( i = 0; i < resize_amount; i++ ) {
00095 data[i] = data[bytes_read + i];
00096 }
00097
00098 data[i] = '\0';
00099 mMsgSize = resize_amount;
00100 */
00101 }
00102
00103 return resize_amount;
00104 }
|
|
||||||||||||||||
|
Assigns the path that this message will follow. The pointer to the next hop in the path is set to the beginning of the path, and any previous path information is lost.
Definition at line 188 of file Message.h. References vprASSERT.
00190 {
00191 mMsgPath = path;
00192 mNextHop = mMsgPath->begin();
00193 mSrcSock = source;
00194 mDestSock = dest;
00195
00196 vprASSERT(mNextHop != mMsgPath->end() && "Path must have at least one value");
00197 }
|
|
|
Returns a constant reference to the path that this message will follow.
Definition at line 202 of file Message.h.
00203 {
00204 return mMsgPath;
00205 }
|
|
|
Definition at line 207 of file Message.h.
00208 {
00209 return mSrcSock;
00210 }
|
|
|
Definition at line 212 of file Message.h.
00213 {
00214 return mDestSock;
00215 }
|
|
|
Retrieves the next hop (network graph vertex) in the path of this message and returns it to the caller via the by-reference parameter.
Definition at line 221 of file Message.h. References vprASSERT.
00222 {
00223 vprASSERT(mMsgPath->end() != mNextHop && "Requesting hop past end of path");
00224 return *mNextHop;
00225 }
|
|
|
Increment the pointer to the next hop in this message's path as it moves towards its destination.
Definition at line 231 of file Message.h.
00232 {
00233 ++mNextHop;
00234 end_of_path = (mMsgPath->end() == mNextHop);
00235 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002