Add logging to default-simulator-impl.cc and fix some outdated documentation.
authorVedran Miletić <rivanvx@gmail.com>
Sat, 06 Oct 2012 21:36:39 +0200
changeset 9103 ad9836bb8e92
parent 9102 48a054b7a3a6
child 9104 5de0d2c78514
Add logging to default-simulator-impl.cc and fix some outdated documentation.
src/core/model/default-simulator-impl.cc
src/core/model/simulator-impl.h
--- a/src/core/model/default-simulator-impl.cc	Fri Oct 05 10:08:41 2012 -0400
+++ b/src/core/model/default-simulator-impl.cc	Sat Oct 06 21:36:39 2012 +0200
@@ -48,6 +48,7 @@
 
 DefaultSimulatorImpl::DefaultSimulatorImpl ()
 {
+  NS_LOG_FUNCTION_NOARGS ();
   m_stop = false;
   // uids are allocated from 4.
   // uid 0 is "invalid" events
@@ -65,11 +66,13 @@
 
 DefaultSimulatorImpl::~DefaultSimulatorImpl ()
 {
+  NS_LOG_FUNCTION_NOARGS ();
 }
 
 void
 DefaultSimulatorImpl::DoDispose (void)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   while (!m_events->IsEmpty ())
     {
       Scheduler::Event next = m_events->RemoveNext ();
@@ -81,6 +84,7 @@
 void
 DefaultSimulatorImpl::Destroy ()
 {
+  NS_LOG_FUNCTION_NOARGS ();
   while (!m_destroyEvents.empty ()) 
     {
       Ptr<EventImpl> ev = m_destroyEvents.front ().PeekEventImpl ();
@@ -96,6 +100,7 @@
 void
 DefaultSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory)
 {
+  NS_LOG_FUNCTION (this << &schedulerFactory);
   Ptr<Scheduler> scheduler = schedulerFactory.Create<Scheduler> ();
 
   if (m_events != 0)
@@ -113,12 +118,14 @@
 uint32_t 
 DefaultSimulatorImpl::GetSystemId (void) const
 {
+  NS_LOG_FUNCTION_NOARGS ();
   return 0;
 }
 
 void
 DefaultSimulatorImpl::ProcessOneEvent (void)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   Scheduler::Event next = m_events->RemoveNext ();
 
   NS_ASSERT (next.key.m_ts >= m_currentTs);
@@ -137,12 +144,14 @@
 bool 
 DefaultSimulatorImpl::IsFinished (void) const
 {
+  NS_LOG_FUNCTION_NOARGS ();
   return m_events->IsEmpty () || m_stop;
 }
 
 void
 DefaultSimulatorImpl::ProcessEventsWithContext (void)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   if (m_eventsWithContextEmpty)
     {
       return;
@@ -173,6 +182,7 @@
 void
 DefaultSimulatorImpl::Run (void)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   // Set the current threadId as the main threadId
   m_main = SystemThread::Self();
   ProcessEventsWithContext ();
@@ -191,12 +201,14 @@
 void 
 DefaultSimulatorImpl::Stop (void)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   m_stop = true;
 }
 
 void 
 DefaultSimulatorImpl::Stop (Time const &time)
 {
+  NS_LOG_FUNCTION (this << time.GetTimeStep ());
   Simulator::Schedule (time, &Simulator::Stop);
 }
 
@@ -206,6 +218,7 @@
 EventId
 DefaultSimulatorImpl::Schedule (Time const &time, EventImpl *event)
 {
+  NS_LOG_FUNCTION (this << time.GetTimeStep () << event);
   NS_ASSERT_MSG (SystemThread::Equals (m_main), "Simulator::Schedule Thread-unsafe invocation!");
 
   Time tAbsolute = time + TimeStep (m_currentTs);
@@ -257,6 +270,7 @@
 EventId
 DefaultSimulatorImpl::ScheduleNow (EventImpl *event)
 {
+  NS_LOG_FUNCTION (this << event);
   NS_ASSERT_MSG (SystemThread::Equals (m_main), "Simulator::ScheduleNow Thread-unsafe invocation!");
 
   Scheduler::Event ev;
@@ -273,6 +287,7 @@
 EventId
 DefaultSimulatorImpl::ScheduleDestroy (EventImpl *event)
 {
+  NS_LOG_FUNCTION (this << event);
   NS_ASSERT_MSG (SystemThread::Equals (m_main), "Simulator::ScheduleDestroy Thread-unsafe invocation!");
 
   EventId id (Ptr<EventImpl> (event, false), m_currentTs, 0xffffffff, 2);
@@ -284,12 +299,14 @@
 Time
 DefaultSimulatorImpl::Now (void) const
 {
+  NS_LOG_FUNCTION_NOARGS ();
   return TimeStep (m_currentTs);
 }
 
 Time 
 DefaultSimulatorImpl::GetDelayLeft (const EventId &id) const
 {
+  NS_LOG_FUNCTION (this << id.GetTs () << id.GetContext () << id.GetUid ());
   if (IsExpired (id))
     {
       return TimeStep (0);
@@ -303,6 +320,7 @@
 void
 DefaultSimulatorImpl::Remove (const EventId &id)
 {
+  NS_LOG_FUNCTION (this << id.GetTs () << id.GetContext () << id.GetUid ());
   if (id.GetUid () == 2)
     {
       // destroy events.
@@ -336,6 +354,7 @@
 void
 DefaultSimulatorImpl::Cancel (const EventId &id)
 {
+  NS_LOG_FUNCTION (this << id.GetTs () << id.GetContext () << id.GetUid ());
   if (!IsExpired (id))
     {
       id.PeekEventImpl ()->Cancel ();
@@ -345,6 +364,7 @@
 bool
 DefaultSimulatorImpl::IsExpired (const EventId &ev) const
 {
+  NS_LOG_FUNCTION (this << ev.GetTs () << ev.GetContext () << ev.GetUid ());
   if (ev.GetUid () == 2)
     {
       if (ev.PeekEventImpl () == 0 ||
@@ -379,6 +399,7 @@
 Time 
 DefaultSimulatorImpl::GetMaximumSimulationTime (void) const
 {
+  NS_LOG_FUNCTION_NOARGS ();
   // XXX: I am fairly certain other compilers use other non-standard
   // post-fixes to indicate 64 bit constants.
   return TimeStep (0x7fffffffffffffffLL);
@@ -387,9 +408,8 @@
 uint32_t
 DefaultSimulatorImpl::GetContext (void) const
 {
+  NS_LOG_FUNCTION_NOARGS ();
   return m_currentContext;
 }
 
 } // namespace ns3
-
-
--- a/src/core/model/simulator-impl.h	Fri Oct 05 10:08:41 2012 -0400
+++ b/src/core/model/simulator-impl.h	Sat Oct 06 21:36:39 2012 +0200
@@ -38,14 +38,11 @@
   static TypeId GetTypeId (void);
 
   /**
-   * Every event scheduled by the Simulator::insertAtDestroy method is
-   * invoked. Then, we ensure that any memory allocated by the 
-   * Simulator is freed.
    * This method is typically invoked at the end of a simulation
    * to avoid false-positive reports by a leak checker.
    * After this method has been invoked, it is actually possible
-   * to restart a new simulation with a set of calls to Simulator::run
-   * and Simulator::insert_*.
+   * to restart a new simulation with a set of calls to Simulator::Run,
+   * Simulator::Schedule and Simulator::ScheduleWithContext.
    */
   virtual void Destroy () = 0;
   /**
@@ -56,12 +53,12 @@
   virtual bool IsFinished (void) const = 0;
   /**
    * If an event invokes this method, it will be the last
-   * event scheduled by the Simulator::run method before
+   * event scheduled by the Simulator::Run method before
    * returning to the caller.
    */
   virtual void Stop (void) = 0;
   /**
-   * Force the Simulator::run method to return to the caller when the
+   * Force the Simulator::Run method to return to the caller when the
    * expiration time of the next event to be processed is greater than
    * or equal to the stop time.  The stop time is relative to the
    * current simulation time.
@@ -119,9 +116,9 @@
    * Set the cancel bit on this event: the event's associated function
    * will not be invoked when it expires. 
    * This method has the same visible effect as the 
-   * ns3::Simulator::remove method but its algorithmic complexity is 
+   * ns3::Simulator::Remove method but its algorithmic complexity is 
    * much lower: it has O(1) complexity.
-   * This method has the exact same semantics as ns3::EventId::cancel.
+   * This method has the exact same semantics as ns3::EventId::Cancel.
    * Note that it is not possible to cancel events which were scheduled
    * for the "destroy" time. Doing so will result in a program error (crash).
    * 
@@ -144,8 +141,8 @@
   /**
    * Run the simulation until one of:
    *   - no events are present anymore
-   *   - the user called Simulator::stop
-   *   - the user called Simulator::stopAtUs and the
+   *   - the user called Simulator::Stop
+   *   - the user called Simulator::Stop with stop time and the
    *     expiration time of the next event to be processed
    *     is greater than or equal to the stop time.
    */