core+main: switch to std::thread and thread_local
Change-Id: I892eb7d87639c2b0d24a8ed457b9d32635269216
diff --git a/tests/core/global-io.t.cpp b/tests/core/global-io.t.cpp
index 5aa3bc6..02f5c4c 100644
--- a/tests/core/global-io.t.cpp
+++ b/tests/core/global-io.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,7 +29,7 @@
#include "tests/rib-io-fixture.hpp"
#include "tests/test-common.hpp"
-#include <boost/thread.hpp>
+#include <thread>
namespace nfd {
namespace tests {
@@ -40,9 +40,9 @@
{
boost::asio::io_service* s1 = &getGlobalIoService();
boost::asio::io_service* s2 = nullptr;
- boost::thread t([&s2] {
- s2 = &getGlobalIoService();
- });
+ std::thread t([&s2] {
+ s2 = &getGlobalIoService();
+ });
t.join();
@@ -60,10 +60,10 @@
BOOST_CHECK(&getGlobalIoService() == mainIo);
BOOST_CHECK(&getMainIoService() == mainIo);
BOOST_CHECK(&getRibIoService() == ribIo);
- auto mainThreadId = boost::this_thread::get_id();
+ auto mainThreadId = std::this_thread::get_id();
runOnRibIoService([&] {
- BOOST_CHECK(mainThreadId != boost::this_thread::get_id());
+ BOOST_CHECK(mainThreadId != std::this_thread::get_id());
BOOST_CHECK(&getGlobalIoService() == ribIo);
BOOST_CHECK(&getMainIoService() == mainIo);
BOOST_CHECK(&getRibIoService() == ribIo);
@@ -71,7 +71,7 @@
runOnRibIoService([&] {
runOnMainIoService([&] {
- BOOST_CHECK(mainThreadId == boost::this_thread::get_id());
+ BOOST_CHECK(mainThreadId == std::this_thread::get_id());
BOOST_CHECK(&getGlobalIoService() == mainIo);
BOOST_CHECK(&getMainIoService() == mainIo);
BOOST_CHECK(&getRibIoService() == ribIo);
@@ -83,7 +83,7 @@
{
bool hasRibRun = false;
runOnRibIoService([&] { hasRibRun = true; });
- boost::this_thread::sleep_for(1_s);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
BOOST_CHECK_EQUAL(hasRibRun, false);
poll();
@@ -107,7 +107,7 @@
{
bool hasRibRun = false;
runOnRibIoService([&] { hasRibRun = true; });
- boost::this_thread::sleep_for(1_s);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
BOOST_CHECK_EQUAL(hasRibRun, false);
advanceClocks(1_ns, 1);
diff --git a/tests/core/scheduler.t.cpp b/tests/core/scheduler.t.cpp
index 88adb03..8e319e0 100644
--- a/tests/core/scheduler.t.cpp
+++ b/tests/core/scheduler.t.cpp
@@ -27,7 +27,7 @@
#include "tests/test-common.hpp"
-#include <boost/thread.hpp>
+#include <thread>
namespace nfd {
namespace scheduler {
@@ -72,7 +72,7 @@
{
scheduler::Scheduler* s1 = &scheduler::getGlobalScheduler();
scheduler::Scheduler* s2 = nullptr;
- boost::thread t([&s2] { s2 = &scheduler::getGlobalScheduler(); });
+ std::thread t([&s2] { s2 = &scheduler::getGlobalScheduler(); });
t.join();
BOOST_CHECK(s1 != nullptr);
diff --git a/tests/rib-io-fixture.cpp b/tests/rib-io-fixture.cpp
index 91fc979..8702994 100644
--- a/tests/rib-io-fixture.cpp
+++ b/tests/rib-io-fixture.cpp
@@ -38,7 +38,7 @@
g_mainIo = &getGlobalIoService();
setMainIoService(g_mainIo);
- g_ribThread = boost::thread([&] {
+ g_ribThread = std::thread([&] {
{
std::lock_guard<std::mutex> lock(m);
g_ribIo = &getGlobalIoService();
diff --git a/tests/rib-io-fixture.hpp b/tests/rib-io-fixture.hpp
index fa43af5..f2bb892 100644
--- a/tests/rib-io-fixture.hpp
+++ b/tests/rib-io-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,9 +27,10 @@
#define NFD_TESTS_RIB_IO_FIXTURE_HPP
#include "tests/test-common.hpp"
-#include <boost/thread.hpp>
+
#include <condition_variable>
#include <mutex>
+#include <thread>
namespace nfd {
namespace tests {
@@ -66,7 +67,7 @@
/** \brief global RIB thread
*/
- boost::thread g_ribThread;
+ std::thread g_ribThread;
private:
bool m_shouldStopRibIo = false;