Bug #270: Simulator::RunOneEvent
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 06 Aug 2008 11:37:52 +0100
changeset 3515 88e9cee20461
parent 3514 308a7d84b18f
child 3516 dacc57c5d31f
child 3517 5ba130a7f519
Bug #270: Simulator::RunOneEvent
bindings/python/ns3_module_simulator.py
src/simulator/default-simulator-impl.cc
src/simulator/default-simulator-impl.h
src/simulator/simulator-impl.h
src/simulator/simulator.cc
src/simulator/simulator.h
--- a/bindings/python/ns3_module_simulator.py	Wed Aug 06 16:11:44 2008 +0100
+++ b/bindings/python/ns3_module_simulator.py	Wed Aug 06 11:37:52 2008 +0100
@@ -367,6 +367,11 @@
                    'void', 
                    [], 
                    is_static=True, unblock_threads=True)
+    ## simulator.h: static void ns3::Simulator::RunOneEvent() [member function]
+    cls.add_method('RunOneEvent', 
+                   'void', 
+                   [], 
+                   is_static=True)
     ## simulator.h: static void ns3::Simulator::Stop() [member function]
     cls.add_method('Stop', 
                    'void', 
@@ -669,6 +674,11 @@
                    'void', 
                    [], 
                    is_pure_virtual=True, is_virtual=True)
+    ## simulator-impl.h: void ns3::SimulatorImpl::RunOneEvent() [member function]
+    cls.add_method('RunOneEvent', 
+                   'void', 
+                   [], 
+                   is_pure_virtual=True, is_virtual=True)
     ## simulator-impl.h: ns3::Time ns3::SimulatorImpl::Now() const [member function]
     cls.add_method('Now', 
                    'ns3::Time', 
@@ -765,6 +775,11 @@
                    'void', 
                    [], 
                    is_virtual=True)
+    ## default-simulator-impl.h: void ns3::DefaultSimulatorImpl::RunOneEvent() [member function]
+    cls.add_method('RunOneEvent', 
+                   'void', 
+                   [], 
+                   is_virtual=True)
     ## default-simulator-impl.h: ns3::Time ns3::DefaultSimulatorImpl::Now() const [member function]
     cls.add_method('Now', 
                    'ns3::Time', 
--- a/src/simulator/default-simulator-impl.cc	Wed Aug 06 16:11:44 2008 +0100
+++ b/src/simulator/default-simulator-impl.cc	Wed Aug 06 11:37:52 2008 +0100
@@ -156,6 +156,12 @@
   NS_ASSERT(!m_events->IsEmpty () || m_unscheduledEvents == 0);
 }
 
+void
+DefaultSimulatorImpl::RunOneEvent (void)
+{
+  ProcessOneEvent ();
+}
+
 void 
 DefaultSimulatorImpl::Stop (void)
 {
--- a/src/simulator/default-simulator-impl.h	Wed Aug 06 16:11:44 2008 +0100
+++ b/src/simulator/default-simulator-impl.h	Wed Aug 06 11:37:52 2008 +0100
@@ -55,6 +55,7 @@
   virtual void Cancel (const EventId &ev);
   virtual bool IsExpired (const EventId &ev) const;
   virtual void Run (void);
+  virtual void RunOneEvent (void);
   virtual Time Now (void) const;
   virtual Time GetDelayLeft (const EventId &id) const;
   virtual Time GetMaximumSimulationTime (void) const;
--- a/src/simulator/simulator-impl.h	Wed Aug 06 16:11:44 2008 +0100
+++ b/src/simulator/simulator-impl.h	Wed Aug 06 11:37:52 2008 +0100
@@ -49,6 +49,7 @@
   virtual void Cancel (const EventId &ev) = 0;
   virtual bool IsExpired (const EventId &ev) const = 0;
   virtual void Run (void) = 0;
+  virtual void RunOneEvent (void) = 0;
   virtual Time Now (void) const = 0;
   virtual Time GetDelayLeft (const EventId &id) const = 0;
   virtual Time GetMaximumSimulationTime (void) const = 0;
--- a/src/simulator/simulator.cc	Wed Aug 06 16:11:44 2008 +0100
+++ b/src/simulator/simulator.cc	Wed Aug 06 11:37:52 2008 +0100
@@ -146,6 +146,13 @@
 }
 
 void 
+Simulator::RunOneEvent (void)
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  GetImpl ()->RunOneEvent ();
+}
+
+void 
 Simulator::Stop (void)
 {
   NS_LOG_LOGIC ("stop");
--- a/src/simulator/simulator.h	Wed Aug 06 16:11:44 2008 +0100
+++ b/src/simulator/simulator.h	Wed Aug 06 11:37:52 2008 +0100
@@ -117,6 +117,11 @@
   static void Run (void);
 
   /**
+   * Process only the next simulation event, then return immediately.
+   */
+  static void RunOneEvent (void);
+
+  /**
    * If an event invokes this method, it will be the last
    * event scheduled by the Simulator::run method before
    * returning to the caller.