network: Add a Remove method to the Queue base class

This commit is contained in:
Stefano Avallone
2016-05-19 00:14:29 +02:00
parent 8d6a5b15ed
commit 8754a59cb6
4 changed files with 53 additions and 2 deletions

View File

@@ -158,6 +158,32 @@ Queue::Dequeue (void)
return item;
}
Ptr<QueueItem>
Queue::Remove (void)
{
NS_LOG_FUNCTION (this);
if (m_nPackets.Get () == 0)
{
NS_LOG_LOGIC ("Queue empty");
return 0;
}
Ptr<QueueItem> item = DoRemove ();
if (item != 0)
{
NS_ASSERT (m_nBytes.Get () >= item->GetPacketSize ());
NS_ASSERT (m_nPackets.Get () > 0);
m_nBytes -= item->GetPacketSize ();
m_nPackets--;
Drop (item);
}
return item;
}
void
Queue::DequeueAll (void)
{