On Sun, 28 Feb 2021, 13:46 Gonzalo Garramuño wrote:
Is there a function to determine whether a piece of code is running on
the main fltk's thread?
Under Win32 that's a call to GetCurrentThreadID(), can't remember the pthread equivalent off the top of my head, but it seemed to work anyway!
int main() {
..
G_main_tid = pthread_self(); // save main thread's
ID
..
}
void some_function() {
if ( G_main_tid == pthread_self() ) {
// main thread
} else {
// child thread
}
}
> std::thread::id const main_thread_id(std::this_thread::get_id());