TEST( EventLoopTest, givenWorkerThreadAndControlThread_whenControlThreadRequstQuitAtAnyTime_thenWorkerThreadShouldQuit) { int argc = 0; QApplication app(argc, nullptr); std::promise> p; std::thread controlThread([future = p.get_future()]() mutable { future.get()->quit(); }); std::thread workerThread([p = std::move(p)]() mutable { auto eventLoop = std::make_shared(); p.set_value(eventLoop); eventLoop->exec(); }); controlThread.join(); workerThread.join(); }