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());
static void InitThread()
Prepare crash log handler for a newly started thread.
Functions to be called to log a crash.
Functions related to debugging.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Error reporting related functions.
void CSleep(int milliseconds)
Sleep on the current thread for a defined time.
bool StartNewThread(std::thread *thr, const char *name, TFn &&_Fx, TArgs &&... _Ax)
Start a new thread.
void SetCurrentThreadName(const char *name)
Name the thread this function is called on for the debugger.
std::mutex lock
synchronization for playback status fields