core: example main-test-sync: use thread and chrono, instead of sleep and usleep

This commit is contained in:
Peter D. Barnes, Jr.
2018-04-16 12:51:49 -07:00
parent 99a6dd59a4
commit 57b7a245d4

View File

@@ -27,8 +27,8 @@
#include "ns3/global-value.h"
#include "ns3/ptr.h"
#include <unistd.h>
#include <sys/time.h>
#include <chrono> // seconds, milliseconds
#include <thread> // 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));
}
}