View | Details | Raw Unified | Return to bug 1000
Collapse All | Expand All

(-)a/examples/realtime/realtime-udp-echo.cc (+1 lines)
 Lines 113-118    Link Here 
113
  //
113
  //
114
  // Now, do the actual simulation.
114
  // Now, do the actual simulation.
115
  //
115
  //
116
  Simulator::Stop (Seconds (11.0));
116
  NS_LOG_INFO ("Run Simulation.");
117
  NS_LOG_INFO ("Run Simulation.");
117
  Simulator::Run ();
118
  Simulator::Run ();
118
  Simulator::Destroy ();
119
  Simulator::Destroy ();
(-)a/src/core/model/realtime-simulator-impl.cc (-14 / +21 lines)
 Lines 428-454    Link Here 
428
  m_running = true;
428
  m_running = true;
429
  m_synchronizer->SetOrigin (m_currentTs);
429
  m_synchronizer->SetOrigin (m_currentTs);
430
430
431
  for (;;) 
431
  // Sleep until signalled
432
  uint64_t tsNow;
433
  uint64_t tsDelay = 1000000000; // wait time of 1 second (in nanoseconds)
434
 
435
  while (!m_stop) 
432
    {
436
    {
433
      bool done = false;
437
      bool process = false;
434
435
      {
438
      {
436
        CriticalSection cs (m_mutex);
439
        CriticalSection cs (m_mutex);
437
        //
440
438
        // In all cases we stop when the event list is empty.  If you are doing a 
441
        if (!m_events->IsEmpty ())
439
        // realtime simulation and you want it to extend out for some time, you must
440
        // call StopAt.  In the realtime case, this will stick a placeholder event out
441
        // at the end of time.
442
        //
443
        if (m_stop || m_events->IsEmpty ())
444
          {
442
          {
445
            done = true;
443
            process = true;
444
          }
445
        else
446
          {
447
            // Get current timestamp while holding the critical section
448
            tsNow = m_synchronizer->GetCurrentRealtime ();
446
          }
449
          }
447
      }
450
      }
451
 
452
      if (!process)
453
        {
454
          // Sleep until signalled
455
          tsNow = m_synchronizer->Synchronize (tsNow, tsDelay);
448
456
449
      if (done)
457
          // Re-check event queue
450
        {
458
          continue;
451
          break;
452
        }
459
        }
453
460
454
      ProcessOneEvent ();
461
      ProcessOneEvent ();

Return to bug 1000