16 #include <system_error>
26 std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
46 template<
class TFn,
class... TArgs>
47 inline bool StartNewThread(std::thread *thr,
const char *name, TFn&& _Fx, TArgs&&... _Ax)
50 static std::mutex thread_startup_mutex;
51 std::lock_guard<std::mutex>
lock(thread_startup_mutex);
53 std::thread t([] (
const char *name, TFn&& F, TArgs&&... A) {
58 std::lock_guard<std::mutex>
lock(thread_startup_mutex);
66 }
catch (std::exception &e) {
67 FatalError(
"Unhandled exception in {} thread: {}", name, e.what());
71 }, name, std::forward<TFn>(_Fx), std::forward<TArgs>(_Ax)...);
80 }
catch (
const std::system_error &e) {
82 Debug(misc, 1,
"Can't create thread '{}': {}", name, e.what());