From 3d4637a939a739e025824f30373f7c9f6e911b27 Mon Sep 17 00:00:00 2001 From: "Christopher A. Mosher" Date: Mon, 5 Dec 2022 23:39:51 -0500 Subject: [PATCH] timeout waiting for wx after 10 secs --- src/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 67e84f9..c7bb6c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -34,7 +35,7 @@ #include #include - +using namespace std::chrono_literals; static std::string parse_args(int argc, char* argv[]) { if (argc > 2) { @@ -66,7 +67,11 @@ static int runSdl(const std::string config_file) { std::thread thread_wx(runWx); std::cout << "wait for wx init" << std::endl; - barrier_to_app_init.wait(); + const std::future_status fut = barrier_to_app_init.wait_for(10s); + if (fut == std::future_status::timeout) { + std::cerr << "timed-out waiting for wx to finish initializing" << std::endl; + return 1; + } std::cout << "wx init finished" << std::endl; std::unique_ptr emu(new Emulator());