Use std::thread in favor of direct pthread access
Change-Id: I7f2927deee84701f3ed7bec86ec97171a5daabb8
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/test/Makefile.am b/test/Makefile.am
index 538d826..1f6470d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -3,6 +3,6 @@
phosphor_inventory_test_SOURCES = \
test.cpp
-phosphor_inventory_test_LDFLAGS = $(SYSTEMD_LIBS)
+phosphor_inventory_test_LDFLAGS = $(SYSTEMD_LIBS) $(PTHREAD_CFLAGS)
phosphor_inventory_test_CFLAGS = $(SYSTEMD_CFLAGS)
phosphor_inventory_test_LDADD = ${top_builddir}/libmanager.la
diff --git a/test/test.cpp b/test/test.cpp
index 550e83f..a35a03b 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -18,20 +18,12 @@
#include <cassert>
#include <iostream>
#include <algorithm>
+#include <thread>
constexpr auto SERVICE = "phosphor.inventory.test";
constexpr auto INTERFACE = IFACE;
constexpr auto ROOT = "/testing/inventory";
-auto server_thread(void* data)
-{
- auto mgr = static_cast<phosphor::inventory::manager::Manager*>(data);
-
- mgr->run();
-
- return static_cast<void*>(nullptr);
-}
-
/** @class SignalQueue
* @brief Store DBus signals in a queue.
*/
@@ -323,15 +315,15 @@
sdbusplus::bus::new_default(),
SERVICE, ROOT, INTERFACE);
- pthread_t t;
+ auto f = [](auto mgr)
{
- pthread_create(&t, nullptr, server_thread, &mgr);
- }
-
+ mgr->run();
+ };
+ auto t = std::thread(f, &mgr);
runTests(mgr);
// Wait for server thread to exit.
- pthread_join(t, nullptr);
+ t.join();
return 0;
}