/******************************************************************* * * DESCRIPTION: Class NCMessageBag * * AUTHOR: Qi (Jacky) Liu * * EMAIL: mailto://liuqi@sce.carleton.ca * * DATE: Sept, 2005 * *******************************************************************/ #ifndef __NC_MESSAGEBAG_H #define __NC_MESSAGEBAG_H #include #include #include #include "VTime.hh" #include "msgbag.h" //base class MessageBag #include "message.h" #include "JackyDebugStream.h" //for jacky-debug-mode /** forward declarations **/ class BasicPortMessage; /*Note: * *This class inherits from class MessageBag. It is for Node Coordinator use only. *The differences between this NCMessageBag and the MessageBag are listed as follows: * *1. Since we cannot assume any synchronization between the node coordinators * on different machines, the NCMessageBag may contain msgs that have different * sendTime. Thus, the add(const BasicPortMessage*) function in class MessageBag is * made virtual to be overridden in this subclass. *2. The "msgtime" in class NCMessageBag should reflect the MIN time stamp among * all msgs in the bag rather than just the common time stamp of the msgs in the * bag. It is used to retrieve those msgs that will be processed simultaneously in * the next simulation cycle. *3. Extra function to retrieve all msgs in the NCMessageBag that have time stamps * equal to the "msgtime". i.e. to get all msgs with the MIN time as a list. These * (X) msgs (sent from other NCs) have the same time stamp (the MIN time) and they * will be processed together. *4. The rollbackCheck() function in the node coordinator will clear all the (X) msgs * in this bag whenever a rollback has happened. * *All other ParallelProcessors, including the flat coordinators and simualtors will *still use the MessageBag that is declared in class ParallelProcessor. The node *coordinator will declare its own NCMessageBag. */ class NCMessageBag : public MessageBag { public: NCMessageBag(); //Default Constructor virtual ~NCMessageBag(); //override the add() function in MessageBag to allow msgs with different //time stamps to be added into the bag virtual MessageBag &add( const BasicPortMessage* ); //this function retrieves all (X) msgs in the bag with time stamp equal //to the "msgtime" (the current MIN time), it returns a list MessageBag::MessageList getMessageWithMinTime(); //this function removes all (X) msgs in the bag with time stamp equal //to the "msgtime" (the current MIN time) void removeMessageWithMinTime(); //this function removes all (X) msgs in the bag with time stamp >= //the given time for rollback purpose void removeMessageWithTimeGreaterOrEqual( const VTime& ); //this function prints out the whole NCMessageBag friend ostream& operator<<(ostream&, const NCMessageBag&); private: //this function advances the msgtime to the new MIN time among the msgs in the bag void calculateNewMin(); }; // NCMessageBag #endif //__NC_MESSAGEBAG_H