forked from CoppeliaRobotics/simUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.cpp
34 lines (28 loc) · 756 Bytes
/
debug.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "debug.h"
#include <sstream>
#include <iostream>
Qt::HANDLE UI_THREAD = NULL;
Qt::HANDLE SIM_THREAD = NULL;
std::string threadNickname()
{
Qt::HANDLE h = QThread::currentThreadId();
if(h == UI_THREAD) return "UI";
if(h == SIM_THREAD) return "SIM";
std::stringstream ss;
ss << h;
return ss.str();
}
void uiThread()
{
Qt::HANDLE h = QThread::currentThreadId();
if(UI_THREAD != NULL && UI_THREAD != h)
std::cerr << "warning: UI thread has already been set" << std::endl;
UI_THREAD = h;
}
void simThread()
{
Qt::HANDLE h = QThread::currentThreadId();
if(SIM_THREAD != NULL && SIM_THREAD != h)
std::cerr << "warning: SIM thread has already been set" << std::endl;
SIM_THREAD = h;
}