Is there way to have the message loop on a secondary thread?
I’d prefer something cross-platform.
I’m writing a library (C++) that exposes a Python API, and will be called interactively from a iPython, so all public functions need to return fairly quickly. This library also needs to run a simulation, and display a window(s). One way to solve this problem is to have the message loop on a background thread. I know this approach works on Windows, but from what I’ve read, causes problems on Mac.
I have read the post which says Cocoa apps need to poll from the main thread, and trying to figure out a way around it: Multithreading GLFW?
What if, on the main thread I installed a signal handler on the main thread, and raised a signal to the same process from a background thread? The signal handler should (I think) be invoked on the main thread, and this here could poll events on the main thread, and return back to listening for console input.