On 27 Jun 2007, at 20:11, Daniel wrote:
>> Threading issues are indeed a concern, but since, afaik, all OS gui
>> toolkits are not really thread safe, fltk's approach is currently not
>> creating any additional issues.
>
> And here I thought fltk was thread safe?

Fltk - like many GUI libraries - is "thread aware" rather than thread  
safe... you can (I usually do) write programs that have multiple  
threads using fltk.
But - you have to be careful where and when you interact with the  
display. (There's only one screen, and only one thread can access it  
at a time without the graphics hardware going screwy...)

Also, since fltk has to work on many different platforms, it has to  
take a conservative approach to how it accesses the display anyway.  
Many (most?) host systems will only allow one thread (usually the main 
() thread) in a threaded program to access the display - so for  
greatest compatibility, fltk follows that pattern.

Now, what this means in practice is that only your main() thread can  
create and destroy windows and widgets, and show the first window  
etc... However, once the widgets exist, you can access and update  
them from any thread - but you need to call Fl::awake() to get the  
main() thread to draw you changes for you, since only it can access  
the display safely...
-- 
Ian

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to