threading and OpenGL - some answers

Hi, I managed to get my openGL threading working and I thought I'd post the results here for the mailing list archives if nothing else. I was already aware that it wouldn't be possible to make openGL calls from another thread unless I took care with forkOS and bound threads. That's ok, because I was planning to do only do openGL in the main thread and just do 'work' in other threads. Just using forkIO naively works, but with some caveats: your worker threads only get processing time as often as your 'idle' callback kicks in, and if they work the CPU hard, the UI becomes unresponsive. The solution to this is (a) compile with ghc -threaded, to use the properly threaded RTS. This makes things quite a bit more responsive (and worker threads run quite happily without needing idle callbacks) but the UI still feels a little sticky. (b) run with +RTS -C0 -RTS to make thread switching more aggressive, or -N2 if you have more than one CPU/core. Then everything works nicely. Jules
participants (1)
-
Jules Bean