From 4891278425e3dc3c8a3e3bb9ce0db48a762f114c Mon Sep 17 00:00:00 2001 From: James Benton Date: Sun, 27 May 2018 12:14:07 +0100 Subject: [PATCH] samples: Update helloworld_std_thread. --- samples/helloworld_std_thread/CMakeLists.txt | 2 ++ samples/helloworld_std_thread/main.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/samples/helloworld_std_thread/CMakeLists.txt b/samples/helloworld_std_thread/CMakeLists.txt index 147c6eb..b4bd2dc 100644 --- a/samples/helloworld_std_thread/CMakeLists.txt +++ b/samples/helloworld_std_thread/CMakeLists.txt @@ -12,7 +12,9 @@ target_link_libraries(helloworld_std_thread proc_ui sysapp) +wut_enable_newlib(helloworld_std_thread) wut_enable_stdcpp(helloworld_std_thread) + wut_create_rpx(helloworld_std_thread.rpx helloworld_std_thread) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/helloworld_std_thread.rpx" diff --git a/samples/helloworld_std_thread/main.cpp b/samples/helloworld_std_thread/main.cpp index 4bb6b0b..08479ea 100644 --- a/samples/helloworld_std_thread/main.cpp +++ b/samples/helloworld_std_thread/main.cpp @@ -11,13 +11,10 @@ int hello_thread() { - OSCalendarTime tm; - - WHBProcInit(); - WHBLogConsoleInit(); WHBLogPrintf("Hello World from a std::thread!"); while(WHBProcIsRunning()) { + OSCalendarTime tm; OSTicksToCalendarTime(OSGetTime(), &tm); WHBLogPrintf("%02d/%02d/%04d %02d:%02d:%02d I'm still here.", tm.tm_mday, tm.tm_mon, tm.tm_year, @@ -30,16 +27,19 @@ hello_thread() WHBLogPrintf("Exiting... good bye."); WHBLogConsoleDraw(); OSSleepTicks(OSMilliseconds(1000)); - - WHBLogConsoleFree(); - WHBProcShutdown(); return 0; } int main(int argc, char **argv) { + WHBProcInit(); + WHBLogConsoleInit(); + std::thread t(hello_thread); t.join(); + + WHBLogConsoleFree(); + WHBProcShutdown(); return 0; }