From 57b7a245d449c5a17edcaa90add01c739ac4ebfb Mon Sep 17 00:00:00 2001 From: "Peter D. Barnes, Jr." Date: Mon, 16 Apr 2018 12:51:49 -0700 Subject: [PATCH] core: example main-test-sync: use thread and chrono, instead of sleep and usleep --- src/core/examples/main-test-sync.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/examples/main-test-sync.cc b/src/core/examples/main-test-sync.cc index 91d1b98e7..9adb5e689 100644 --- a/src/core/examples/main-test-sync.cc +++ b/src/core/examples/main-test-sync.cc @@ -27,8 +27,8 @@ #include "ns3/global-value.h" #include "ns3/ptr.h" -#include -#include +#include // seconds, milliseconds +#include // sleep_for /** * \file @@ -96,14 +96,15 @@ void FakeNetDevice::Doit3 (void) { NS_LOG_FUNCTION_NOARGS (); - sleep (1); + std::this_thread::sleep_for (std::chrono::seconds(1)); + for (uint32_t i = 0; i < 10000; ++i) { // // Exercise the realtime relative now path // Simulator::ScheduleWithContext(Simulator::NO_CONTEXT, Seconds(0.0), MakeEvent (&inserted_function)); - usleep (1000); + std::this_thread::sleep_for (std::chrono::milliseconds(1)); } }