AbstractQueue Class Reference

#include <AbstractQueue.h>

Inheritance diagram for AbstractQueue:

QueueBase QueueWithQoS IP IPv6

List of all members.


Detailed Description

Abstract base class for single-server queues. Contains special optimization for zero service time (i.e. it does not schedule the endService timer then).

Public Member Functions

 AbstractQueue ()
virtual ~AbstractQueue ()

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)
virtual void arrival (cPacket *msg)=0
virtual cPacket * arrivalWhenIdle (cPacket *msg)=0
virtual simtime_t startService (cPacket *msg)=0
virtual void endService (cPacket *msg)=0

Protected Attributes

cPacketQueue queue

Private Member Functions

void doStartService ()
void doEndService ()

Private Attributes

cPacket * msgServiced
cMessage * endServiceMsg

Constructor & Destructor Documentation

AbstractQueue::AbstractQueue (  ) 

00024 {
00025     msgServiced = NULL;
00026     endServiceMsg = NULL;
00027 }

AbstractQueue::~AbstractQueue (  )  [virtual]

00030 {
00031     delete msgServiced;
00032     cancelAndDelete(endServiceMsg);
00033 }


Member Function Documentation

void AbstractQueue::doStartService (  )  [private]

Referenced by doEndService(), and handleMessage().

00065 {
00066     simtime_t serviceTime = startService( msgServiced );
00067     if (serviceTime != 0)
00068         scheduleAt( simTime()+serviceTime, endServiceMsg );
00069     else
00070         doEndService();
00071 }

void AbstractQueue::doEndService (  )  [private]

Referenced by doStartService(), and handleMessage().

00074 {
00075     endService( msgServiced );
00076     if (queue.empty())
00077     {
00078         msgServiced = NULL;
00079     }
00080     else
00081     {
00082         msgServiced = queue.pop();
00083         doStartService();
00084     }
00085 }

void AbstractQueue::initialize (  )  [protected, virtual]

Reimplemented in QueueBase, QueueWithQoS, IP, and IPv6.

Referenced by QueueWithQoS::initialize(), and QueueBase::initialize().

00036 {
00037     msgServiced = NULL;
00038     endServiceMsg = new cMessage("end-service");
00039     queue.setName("queue");
00040 }

void AbstractQueue::handleMessage ( cMessage *  msg  )  [protected, virtual]

00043 {
00044     if (msg==endServiceMsg)
00045     {
00046         doEndService();
00047     }
00048     else if (!msgServiced)
00049     {
00050         cPacket *msg2 = arrivalWhenIdle( PK(msg) );
00051         if (msg2)
00052         {
00053             msgServiced = msg2;
00054             doStartService();
00055         }
00056 
00057     }
00058     else
00059     {
00060         arrival( PK(msg) );
00061     }
00062 }

virtual void AbstractQueue::arrival ( cPacket *  msg  )  [protected, pure virtual]

Functions to (re)define behaviour Called when a message arrives at the module. The method should either enqueue this message (usual behaviour), or discard it. It may also wrap the it into another message, and insert that one in the queue.

Most straightforward implementation: queue.insert(msg);

Implemented in QueueBase, and QueueWithQoS.

Referenced by handleMessage().

virtual cPacket* AbstractQueue::arrivalWhenIdle ( cPacket *  msg  )  [protected, pure virtual]

Called when a message arrives at the module when the queue is empty. The message doesn't need to be enqueued in this case, it can start service immmediately. This method may:

  1. simply return the the same pointer (usual behaviour), or
  2. discard the message and return NULL pointer (the effect being this message being ignored)
  3. or modify the message, wrap in into another message etc, and return the (new) message's pointer.

Most straightforward implementation: return msg;

Implemented in QueueBase, and QueueWithQoS.

Referenced by handleMessage().

virtual simtime_t AbstractQueue::startService ( cPacket *  msg  )  [protected, pure virtual]

Called when a message starts service, and should return the service time.

Example implementation: return 1.0;

Implemented in QueueBase, and QueueWithQoS.

Referenced by doStartService().

virtual void AbstractQueue::endService ( cPacket *  msg  )  [protected, pure virtual]

Called when a message completes service. The function may send it to another module, discard it, or in general do anything with it.

Most straightforward implementation: send(msg,"out");

Implemented in IP, and IPv6.

Referenced by doEndService().


Member Data Documentation

cPacket* AbstractQueue::msgServiced [private]

cMessage* AbstractQueue::endServiceMsg [private]

cPacketQueue AbstractQueue::queue [protected]


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

Generated on Fri Mar 20 18:51:18 2009 for INET Framework for OMNeT++/OMNEST by  doxygen 1.5.5