core: Simulator::GetEventCount()
This commit is contained in:
@@ -71,6 +71,7 @@ DefaultSimulatorImpl::DefaultSimulatorImpl ()
|
||||
m_currentTs = 0;
|
||||
m_currentContext = Simulator::NO_CONTEXT;
|
||||
m_unscheduledEvents = 0;
|
||||
m_eventCount = 0;
|
||||
m_eventsWithContextEmpty = true;
|
||||
m_main = SystemThread::Self();
|
||||
}
|
||||
@@ -141,6 +142,7 @@ DefaultSimulatorImpl::ProcessOneEvent (void)
|
||||
|
||||
NS_ASSERT (next.key.m_ts >= m_currentTs);
|
||||
m_unscheduledEvents--;
|
||||
m_eventCount++;
|
||||
|
||||
NS_LOG_LOGIC ("handle " << next.key.m_ts);
|
||||
m_currentTs = next.key.m_ts;
|
||||
@@ -411,4 +413,10 @@ DefaultSimulatorImpl::GetContext (void) const
|
||||
return m_currentContext;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
DefaultSimulatorImpl::GetEventCount (void) const
|
||||
{
|
||||
return m_eventCount;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -77,6 +77,7 @@ public:
|
||||
virtual void SetScheduler (ObjectFactory schedulerFactory);
|
||||
virtual uint32_t GetSystemId (void) const;
|
||||
virtual uint32_t GetContext (void) const;
|
||||
virtual uint64_t GetEventCount (void) const;;
|
||||
|
||||
private:
|
||||
virtual void DoDispose (void);
|
||||
@@ -124,6 +125,8 @@ private:
|
||||
uint64_t m_currentTs;
|
||||
/** Execution context of the current event. */
|
||||
uint32_t m_currentContext;
|
||||
/** The event count. */
|
||||
uint64_t m_eventCount;
|
||||
/**
|
||||
* Number of events that have been inserted but not yet scheduled,
|
||||
* not counting the Destroy events; this is used for validation
|
||||
|
||||
@@ -90,6 +90,7 @@ RealtimeSimulatorImpl::RealtimeSimulatorImpl ()
|
||||
m_currentTs = 0;
|
||||
m_currentContext = Simulator::NO_CONTEXT;
|
||||
m_unscheduledEvents = 0;
|
||||
m_eventCount = 0;
|
||||
|
||||
m_main = SystemThread::Self();
|
||||
|
||||
@@ -330,6 +331,7 @@ RealtimeSimulatorImpl::ProcessOneEvent (void)
|
||||
"RealtimeSimulatorImpl::ProcessOneEvent(): event queue is empty");
|
||||
next = m_events->RemoveNext ();
|
||||
m_unscheduledEvents--;
|
||||
m_eventCount++;
|
||||
|
||||
//
|
||||
// We cannot make any assumption that "next" is the same event we originally waited
|
||||
@@ -817,6 +819,12 @@ RealtimeSimulatorImpl::GetContext (void) const
|
||||
return m_currentContext;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
RealTimeSimulatorImpl::GetEventCount (void) const
|
||||
{
|
||||
return m_eventCount;
|
||||
}
|
||||
|
||||
void
|
||||
RealtimeSimulatorImpl::SetSynchronizationMode (enum SynchronizationMode mode)
|
||||
{
|
||||
|
||||
@@ -107,6 +107,7 @@ public:
|
||||
virtual void SetScheduler (ObjectFactory schedulerFactory);
|
||||
virtual uint32_t GetSystemId (void) const;
|
||||
virtual uint32_t GetContext (void) const;
|
||||
virtual uint64_t GetEventCount (void) const;;
|
||||
|
||||
/** \copydoc ScheduleWithContext(uint32_t,const Time&,EventImpl*) */
|
||||
void ScheduleRealtimeWithContext (uint32_t context, const Time &delay, EventImpl *event);
|
||||
@@ -202,6 +203,8 @@ private:
|
||||
uint64_t m_currentTs;
|
||||
/**< Execution context. */
|
||||
uint32_t m_currentContext;
|
||||
/** The event count. */
|
||||
uint64_t m_eventCount;
|
||||
/**@}*/
|
||||
|
||||
/** Mutex to control access to key state. */
|
||||
|
||||
@@ -99,6 +99,9 @@ public:
|
||||
virtual uint32_t GetSystemId () const = 0;
|
||||
/** \copydoc Simulator::GetContext */
|
||||
virtual uint32_t GetContext (void) const = 0;
|
||||
/** \copydoc Simulator::GetEventCount */
|
||||
virtual uint64_t GetEventCount (void) const = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -323,6 +323,12 @@ Simulator::GetContext (void)
|
||||
{
|
||||
return GetImpl ()->GetContext ();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Simulator::GetEventCount (void)
|
||||
{
|
||||
return GetImpl ()-> GetEventCount ();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Simulator::GetSystemId (void)
|
||||
|
||||
@@ -197,7 +197,14 @@ public:
|
||||
*/
|
||||
NO_CONTEXT = 0xffffffff
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the number of events executed.
|
||||
* \returns The total number of events executed.
|
||||
*/
|
||||
static uint64_t GetEventCount (void);
|
||||
|
||||
|
||||
/**
|
||||
* @name Schedule events (in the same context) to run at a future time.
|
||||
*/
|
||||
@@ -1347,7 +1354,8 @@ private:
|
||||
* @return The EventId.
|
||||
*/
|
||||
static EventId DoScheduleDestroy (EventImpl *event);
|
||||
};
|
||||
|
||||
}; // class Simulator
|
||||
|
||||
/**
|
||||
* @ingroup simulator
|
||||
|
||||
@@ -105,6 +105,7 @@ DistributedSimulatorImpl::DistributedSimulatorImpl ()
|
||||
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
|
||||
#endif
|
||||
|
||||
m_eventCount = 0;
|
||||
m_stop = false;
|
||||
m_globalFinished = false;
|
||||
// uids are allocated from 4.
|
||||
@@ -117,6 +118,7 @@ DistributedSimulatorImpl::DistributedSimulatorImpl ()
|
||||
m_currentTs = 0;
|
||||
m_currentContext = Simulator::NO_CONTEXT;
|
||||
m_unscheduledEvents = 0;
|
||||
m_eventCount = 0;
|
||||
m_events = 0;
|
||||
}
|
||||
|
||||
@@ -322,6 +324,7 @@ DistributedSimulatorImpl::ProcessOneEvent (void)
|
||||
|
||||
NS_ASSERT (next.key.m_ts >= m_currentTs);
|
||||
m_unscheduledEvents--;
|
||||
m_eventCount++;
|
||||
|
||||
NS_LOG_LOGIC ("handle " << next.key.m_ts);
|
||||
m_currentTs = next.key.m_ts;
|
||||
@@ -644,4 +647,10 @@ DistributedSimulatorImpl::GetContext (void) const
|
||||
return m_currentContext;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
DistributedSimulatorImpl::GetEventCount (void) const
|
||||
{
|
||||
return m_eventCount;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -126,6 +126,7 @@ public:
|
||||
virtual void SetScheduler (ObjectFactory schedulerFactory);
|
||||
virtual uint32_t GetSystemId (void) const;
|
||||
virtual uint32_t GetContext (void) const;
|
||||
virtual uint64_t GetEventCount (void) const;;
|
||||
|
||||
private:
|
||||
virtual void DoDispose (void);
|
||||
@@ -145,6 +146,8 @@ private:
|
||||
uint32_t m_currentUid;
|
||||
uint64_t m_currentTs;
|
||||
uint32_t m_currentContext;
|
||||
/** The event count. */
|
||||
uint64_t m_eventCount;
|
||||
// number of events that have been inserted but not yet scheduled,
|
||||
// not counting the "destroy" events; this is used for validation
|
||||
int m_unscheduledEvents;
|
||||
|
||||
@@ -84,6 +84,7 @@ NullMessageSimulatorImpl::NullMessageSimulatorImpl ()
|
||||
m_currentTs = 0;
|
||||
m_currentContext = Simulator::NO_CONTEXT;
|
||||
m_unscheduledEvents = 0;
|
||||
m_eventCount = 0;
|
||||
m_events = 0;
|
||||
|
||||
m_safeTime = Seconds (0);
|
||||
@@ -235,6 +236,7 @@ NullMessageSimulatorImpl::ProcessOneEvent (void)
|
||||
|
||||
NS_ASSERT (next.key.m_ts >= m_currentTs);
|
||||
m_unscheduledEvents--;
|
||||
m_eventCount++;
|
||||
|
||||
NS_LOG_LOGIC ("handle " << next.key.m_ts);
|
||||
m_currentTs = next.key.m_ts;
|
||||
@@ -575,6 +577,12 @@ NullMessageSimulatorImpl::GetContext (void) const
|
||||
return m_currentContext;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
NullMessageSimulatorImpl::GetEventCount (void) const
|
||||
{
|
||||
return m_eventCount;
|
||||
}
|
||||
|
||||
Time NullMessageSimulatorImpl::CalculateGuaranteeTime (uint32_t nodeSysId)
|
||||
{
|
||||
Ptr<RemoteChannelBundle> bundle = RemoteChannelBundleManager::Find (nodeSysId);
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
virtual void SetScheduler (ObjectFactory schedulerFactory);
|
||||
virtual uint32_t GetSystemId (void) const;
|
||||
virtual uint32_t GetContext (void) const;
|
||||
virtual uint64_t GetEventCount (void) const;;
|
||||
|
||||
/**
|
||||
* \return singleton instance
|
||||
@@ -176,6 +177,8 @@ private:
|
||||
uint32_t m_currentUid;
|
||||
uint64_t m_currentTs;
|
||||
uint32_t m_currentContext;
|
||||
/** The event count. */
|
||||
uint64_t m_eventCount;
|
||||
// number of events that have been inserted but not yet scheduled,
|
||||
// not counting the "destroy" events; this is used for validation
|
||||
int m_unscheduledEvents;
|
||||
|
||||
@@ -216,6 +216,12 @@ VisualSimulatorImpl::GetContext (void) const
|
||||
return m_simulator->GetContext ();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
VisualSimulatorImpl::GetEventCount (void) const
|
||||
{
|
||||
return m_simulator->GetEventCount ();
|
||||
}
|
||||
|
||||
void
|
||||
VisualSimulatorImpl::RunRealSimulator (void)
|
||||
{
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
virtual void SetScheduler (ObjectFactory schedulerFactory);
|
||||
virtual uint32_t GetSystemId (void) const;
|
||||
virtual uint32_t GetContext (void) const;
|
||||
virtual uint64_t GetEventCount (void) const;;
|
||||
|
||||
/// calls Run() in the wrapped simulator
|
||||
void RunRealSimulator (void);
|
||||
|
||||
Reference in New Issue
Block a user