Modify thread control 32/300932/2
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 6 Nov 2023 07:18:15 +0000 (16:18 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 6 Nov 2023 07:30:58 +0000 (16:30 +0900)
This patch uses std::condition_variable::wait_for() instead of
std::condition_variable::wait(). The timeout is 5 seconds.

Change-Id: I6a5f89bbf4450679c8527121f76966c6451eab52
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/launchpad/thread_control.cc

index 41b2ed1..680b305 100644 (file)
@@ -177,9 +177,12 @@ void ThreadControl::SignalHandler(int signo) {
   auto& inst = ThreadControl::GetInst();
   std::unique_lock<std::mutex> lock(inst.mutex_);
   inst.count_--;
-  inst.cond_.wait(lock, [&] { return inst.done_; });
+  if (inst.cond_.wait_for(lock, std::chrono::seconds(5),
+                          [&] { return inst.done_; }))
+    _D("Unblock");
+  else
+    _E("Timed out");
   inst.count_--;
-  _D("Unblock");
 }
 
 }  // namespace launchpad