network: ScheduleNow() not only the wake callback, but also the check on its condition
The wake callback is scheduled "now" to let the flow of operations associated with dequeue/remove complete before the flow control mechanism is triggered. Move the check on the conditions for calling the wake callback after the flow of operations is completed as well, in case the latter affect such conditions.
This commit is contained in:
committed by
Stefano Avallone
parent
a14525f632
commit
aa9cefe502
@@ -22,7 +22,6 @@
|
||||
#include "ns3/abort.h"
|
||||
#include "ns3/queue-item.h"
|
||||
#include "ns3/queue-limits.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
namespace ns3
|
||||
@@ -89,7 +88,7 @@ NetDeviceQueue::Wake()
|
||||
// Request the queue disc to dequeue a packet
|
||||
if (wasStoppedByDevice && !m_wakeCallback.IsNull())
|
||||
{
|
||||
Simulator::ScheduleNow(&NetDeviceQueue::m_wakeCallback, this);
|
||||
m_wakeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +141,7 @@ NetDeviceQueue::NotifyTransmittedBytes(uint32_t bytes)
|
||||
// Request the queue disc to dequeue a packet
|
||||
if (wasStoppedByQueueLimits && !m_wakeCallback.IsNull())
|
||||
{
|
||||
Simulator::ScheduleNow(&NetDeviceQueue::m_wakeCallback, this);
|
||||
m_wakeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "ns3/object-factory.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/simulator.h"
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
@@ -361,19 +362,21 @@ void
|
||||
NetDeviceQueue::PacketDequeued(QueueType* queue, Ptr<const typename QueueType::ItemType> item)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << queue << item);
|
||||
|
||||
// Inform BQL
|
||||
NotifyTransmittedBytes(item->GetSize());
|
||||
|
||||
NS_ASSERT_MSG(m_device, "Aggregated NetDevice not set");
|
||||
// After dequeuing a packet, if there is room for another packet we
|
||||
// call Wake () that ensures that the queue is not stopped and restarts
|
||||
// the queue disc if the queue was stopped
|
||||
|
||||
if (!queue->WouldOverflow(1, m_device->GetMtu()))
|
||||
{
|
||||
Wake();
|
||||
}
|
||||
Simulator::ScheduleNow([=]() {
|
||||
// Inform BQL
|
||||
NotifyTransmittedBytes(item->GetSize());
|
||||
|
||||
// After dequeuing a packet, if there is room for another packet we
|
||||
// call Wake () that ensures that the queue is not stopped and restarts
|
||||
// the queue disc if the queue was stopped
|
||||
|
||||
if (!queue->WouldOverflow(1, m_device->GetMtu()))
|
||||
{
|
||||
Wake();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
template <typename QueueType>
|
||||
|
||||
Reference in New Issue
Block a user