openMSX
Thread.cc
Go to the documentation of this file.
1#include "Thread.hh"
2#include <cassert>
3#include <thread>
4
5namespace openmsx::Thread {
6
7static std::thread::id mainThreadId;
8
10{
11 assert(mainThreadId == std::thread::id());
12 mainThreadId = std::this_thread::get_id();
13}
14
16{
17 assert(mainThreadId != std::thread::id());
18 return mainThreadId == std::this_thread::get_id();
19}
20
21} // namespace openmsx::Thread
void setMainThread()
Store ID of the main thread, should be called exactly once from the main thread.
Definition Thread.cc:9
bool isMainThread()
Returns true when called from the main thread.
Definition Thread.cc:15