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