Re: Use worker thread to call Fl_Window and Fl_run
Paul Hahn
Sep 30, 2020
So if you can create and show all the window objects in your main thread, then arrange for Fl::wait() to be called periodically from the main thread, that ought to just about do the job.
Yes I did that when I wrote an animated "wait window widget" based on a threading solution. A lot of bad things happened unexpectedly until I finally got a handle on how to deal with ensuring FLTK updates happen only in the main thread.
In retrospect, all my initial problems were due to not respecting the FLTK documentned warning to use their lock mechanism for multi-threaded solutions. I definitely respect that now, even though I wound up probably sort of duplicating what it does in my own way (i.e., my own version of Fl::run() and Fl::awake() only implemented with Bohm-atomic "mutexes"). I would utilize the FLTK locking mechanism if I had to do it all over again.
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.