merge with HEAD
authorMathieu Lacage <mathieu.lacage@cutebugs.net>
Fri, 23 Mar 2012 08:38:57 +0100
changeset 7785 64726e51f268
parent 7784 549a235e73a1 (current diff)
parent 7783 df921ace5e20 (diff)
child 7786 715b25bff41d
merge with HEAD
--- a/src/core/examples/main-test-sync.cc	Fri Mar 23 07:38:42 2012 +0100
+++ b/src/core/examples/main-test-sync.cc	Fri Mar 23 08:38:57 2012 +0100
@@ -48,7 +48,6 @@
 public:
   FakeNetDevice ();
   void Doit3 (void);
-  void Doit4 (void);
 };
 
 FakeNetDevice::FakeNetDevice ()
@@ -66,25 +65,11 @@
       //
       // Exercise the realtime relative now path
       //
-      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (MakeEvent (&inserted_function));
+      Simulator::ScheduleWithContext(0xffffffff, Seconds(0.0), MakeEvent (&inserted_function));
       usleep (1000);
     }
 }
 
-void
-FakeNetDevice::Doit4 (void)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  sleep (1);
-  for (uint32_t i = 0; i < 10000; ++i)
-    {
-      //
-      // Exercise the realtime relative schedule path
-      //
-      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtime (Seconds (0), MakeEvent (&inserted_function));
-      usleep (1000);
-    }
-}
 
 void 
 test (void)
@@ -97,7 +82,7 @@
   // 
   // Make sure ScheduleNow works when the system isn't running
   //
-  DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (MakeEvent (&first_function));
+  Simulator::ScheduleWithContext(0xffffffff, Seconds(0.0), MakeEvent (&first_function));
 
   // 
   // drive the progression of m_currentTs at a ten millisecond rate from the main thread
@@ -111,14 +96,9 @@
       MakeCallback (&FakeNetDevice::Doit3, &fnd));
   st3->Start ();
 
-  Ptr<SystemThread> st4 = Create<SystemThread> (
-      MakeCallback (&FakeNetDevice::Doit4, &fnd));
-  st4->Start ();
-
   Simulator::Stop (Seconds (15.0));
   Simulator::Run ();
   st3->Join ();
-  st4->Join ();
   Simulator::Destroy ();
 }
 
--- a/src/emu/model/emu-net-device.cc	Fri Mar 23 07:38:42 2012 +0100
+++ b/src/emu/model/emu-net-device.cc	Fri Mar 23 08:38:57 2012 +0100
@@ -272,26 +272,6 @@
     }
 
   //
-  // We're going to need a pointer to the realtime simulator implementation.
-  // It's important to remember that access to that implementation may happen 
-  // in a completely different thread than the simulator is running in (we're 
-  // going to spin up that thread below).  We are talking about multiple threads
-  // here, so it is very, very dangerous to do any kind of reference couning on
-  // a shared object that is unaware of what is happening.  What we are going to 
-  // do to address that is to get a reference to the realtime simulator here 
-  // where we are running in the context of a running simulator scheduler --
-  // recall we did a Simulator::Schedule of this method above.  We get the
-  // simulator implementation pointer in a single-threaded way and save the
-  // underlying raw pointer for use by the (other) read thread.  We must not
-  // free this pointer or we may delete the simulator out from under us an 
-  // everyone else.  We assume that the simulator implementation cannot be 
-  // replaced while the emu device is running and so will remain valid through
-  // the time during which the read thread is running.
-  //
-  Ptr<RealtimeSimulatorImpl> impl = DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ());
-  m_rtImpl = GetPointer (impl);
-
-  //
   // A similar story exists for the node ID.  We can't just naively do a
   // GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
   // is reference counted.  We need to stash away the node ID for use in the
@@ -823,8 +803,8 @@
 
       NS_LOG_INFO ("EmuNetDevice::EmuNetDevice(): Received packet on node " << m_nodeId);
       NS_LOG_INFO ("EmuNetDevice::ReadThread(): Scheduling handler");
-      NS_ASSERT_MSG (m_rtImpl, "EmuNetDevice::ReadThread(): Realtime simulator implementation pointer not set");
-      m_rtImpl->ScheduleRealtimeNowWithContext (m_nodeId, MakeEvent (&EmuNetDevice::ForwardUp, this, buf, len));
+      Simulator::ScheduleWithContext (m_nodeId, Seconds (0.0),
+                                      MakeEvent (&EmuNetDevice::ForwardUp, this, buf, len));
       buf = 0;
     }
 }
--- a/src/emu/model/emu-net-device.h	Fri Mar 23 07:38:42 2012 +0100
+++ b/src/emu/model/emu-net-device.h	Fri Mar 23 08:38:57 2012 +0100
@@ -33,7 +33,6 @@
 #include "ns3/mac48-address.h"
 #include "ns3/system-thread.h"
 #include "ns3/system-mutex.h"
-#include "ns3/realtime-simulator-impl.h"
 
 namespace ns3 {
 
@@ -517,12 +516,6 @@
    */
   uint8_t *m_packetBuffer;
 
-  /**
-   * A copy of a raw pointer to the required real-time simulator implementation.
-   * Never free this pointer!
-   */
-  RealtimeSimulatorImpl *m_rtImpl;
-
   /*
    * a copy of the node id so the read thread doesn't have to GetNode() in
    * in order to find the node ID.  Thread unsafe reference counting in 
--- a/src/tap-bridge/model/tap-bridge.cc	Fri Mar 23 07:38:42 2012 +0100
+++ b/src/tap-bridge/model/tap-bridge.cc	Fri Mar 23 08:38:57 2012 +0100
@@ -215,26 +215,6 @@
   NS_ABORT_MSG_IF (m_sock != -1, "TapBridge::StartTapDevice(): Tap is already started");
 
   //
-  // We're going to need a pointer to the realtime simulator implementation.
-  // It's important to remember that access to that implementation may happen 
-  // in a completely different thread than the simulator is running in (we're 
-  // going to spin up that thread below).  We are talking about multiple threads
-  // here, so it is very, very dangerous to do any kind of reference couning on
-  // a shared object that is unaware of what is happening.  What we are going to 
-  // do to address that is to get a reference to the realtime simulator here 
-  // where we are running in the context of a running simulator scheduler --
-  // recall we did a Simulator::Schedule of this method above.  We get the
-  // simulator implementation pointer in a single-threaded way and save the
-  // underlying raw pointer for use by the (other) read thread.  We must not
-  // free this pointer or we may delete the simulator out from under us an 
-  // everyone else.  We assume that the simulator implementation cannot be 
-  // replaced while the tap bridge is running and so will remain valid through
-  // the time during which the read thread is running.
-  //
-  Ptr<RealtimeSimulatorImpl> impl = DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ());
-  m_rtImpl = GetPointer (impl);
-
-  //
   // A similar story exists for the node ID.  We can't just naively do a
   // GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
   // is reference counted.  We need to stash away the node ID for use in the
@@ -684,8 +664,7 @@
 
   NS_LOG_INFO ("TapBridge::ReadCallback(): Received packet on node " << m_nodeId);
   NS_LOG_INFO ("TapBridge::ReadCallback(): Scheduling handler");
-  NS_ASSERT_MSG (m_rtImpl, "TapBridge::ReadCallback(): Realtime simulator implementation pointer not set");
-  m_rtImpl->ScheduleRealtimeNowWithContext (m_nodeId, MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
+  Simulator::ScheduleWithContext (m_nodeId, Seconds (0.0), MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
 }
 
 void
--- a/src/tap-bridge/model/tap-bridge.h	Fri Mar 23 07:38:42 2012 +0100
+++ b/src/tap-bridge/model/tap-bridge.h	Fri Mar 23 08:38:57 2012 +0100
@@ -32,7 +32,6 @@
 #include "ns3/ptr.h"
 #include "ns3/mac48-address.h"
 #include "ns3/unix-fd-reader.h"
-#include "ns3/realtime-simulator-impl.h"
 
 namespace ns3 {
 
@@ -458,12 +457,6 @@
    */
   uint8_t *m_packetBuffer;
 
-  /**
-   * A copy of a raw pointer to the required real-time simulator implementation.
-   * Never free this pointer!
-   */
-  RealtimeSimulatorImpl *m_rtImpl;
-
   /*
    * a copy of the node id so the read thread doesn't have to GetNode() in
    * in order to find the node ID.  Thread unsafe reference counting in