core: pre-event hook, to facilitate chaining SimulatorImpls
This commit is contained in:
@@ -20,11 +20,8 @@
|
||||
|
||||
#include "simulator.h"
|
||||
#include "default-simulator-impl.h"
|
||||
#include "scheduler.h"
|
||||
#include "event-impl.h"
|
||||
|
||||
#include "ptr.h"
|
||||
#include "pointer.h"
|
||||
#include "scheduler.h"
|
||||
#include "assert.h"
|
||||
#include "log.h"
|
||||
|
||||
@@ -135,6 +132,9 @@ DefaultSimulatorImpl::ProcessOneEvent (void)
|
||||
{
|
||||
Scheduler::Event next = m_events->RemoveNext ();
|
||||
|
||||
PreEventHook (EventId (next.impl, next.key.m_ts,
|
||||
next.key.m_context, next.key.m_uid));
|
||||
|
||||
NS_ASSERT (next.key.m_ts >= m_currentTs);
|
||||
m_unscheduledEvents--;
|
||||
m_eventCount++;
|
||||
|
||||
@@ -22,13 +22,9 @@
|
||||
#define DEFAULT_SIMULATOR_IMPL_H
|
||||
|
||||
#include "simulator-impl.h"
|
||||
#include "scheduler.h"
|
||||
#include "event-impl.h"
|
||||
#include "system-thread.h"
|
||||
#include "system-mutex.h"
|
||||
|
||||
#include "ptr.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
/**
|
||||
@@ -39,6 +35,9 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
// Forward
|
||||
class Scheduler;
|
||||
|
||||
/**
|
||||
* \ingroup simulator
|
||||
*
|
||||
|
||||
@@ -325,6 +325,10 @@ RealtimeSimulatorImpl::ProcessOneEvent (void)
|
||||
NS_ASSERT_MSG (m_events->IsEmpty () == false,
|
||||
"RealtimeSimulatorImpl::ProcessOneEvent(): event queue is empty");
|
||||
next = m_events->RemoveNext ();
|
||||
|
||||
PreEventHook (EventId (next.impl, next.key.m_ts,
|
||||
next.key.m_context, next.key.m_uid));
|
||||
|
||||
m_unscheduledEvents--;
|
||||
m_eventCount++;
|
||||
|
||||
|
||||
@@ -102,6 +102,13 @@ public:
|
||||
/** \copydoc Simulator::GetEventCount */
|
||||
virtual uint64_t GetEventCount (void) const = 0;
|
||||
|
||||
/**
|
||||
* Hook called before processing each event.
|
||||
*
|
||||
* \param [in] id The event about to be processed.
|
||||
*/
|
||||
virtual void PreEventHook (const EventId & id) {};
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -309,6 +309,9 @@ DistributedSimulatorImpl::ProcessOneEvent (void)
|
||||
|
||||
Scheduler::Event next = m_events->RemoveNext ();
|
||||
|
||||
PreEventHook (EventId (next.impl, next.key.m_ts,
|
||||
next.key.m_context, next.key.m_uid));
|
||||
|
||||
NS_ASSERT (next.key.m_ts >= m_currentTs);
|
||||
m_unscheduledEvents--;
|
||||
m_eventCount++;
|
||||
|
||||
@@ -230,6 +230,9 @@ NullMessageSimulatorImpl::ProcessOneEvent (void)
|
||||
|
||||
Scheduler::Event next = m_events->RemoveNext ();
|
||||
|
||||
PreEventHook (EventId (next.impl, next.key.m_ts,
|
||||
next.key.m_context, next.key.m_uid));
|
||||
|
||||
NS_ASSERT (next.key.m_ts >= m_currentTs);
|
||||
m_unscheduledEvents--;
|
||||
m_eventCount++;
|
||||
|
||||
Reference in New Issue
Block a user