On 04/16/13 06:15, Andrew wrote: > All process of work with text editor is based on work with text buffer > ( which in my design is unique for each window) and reacting on buttons > callbacks like copy, open,etc.
One thing of importance; Fl_Text_Editor uses the Fl_Text_Buffer to render itself, so you have to be sure if a thread is fiddling around with Fl_Text_Buffer, the main thread has been put to sleep while it does its work. I suppose speed wise this will not be much different. It would only be different if you had multiple threads working at the same time, and even then, if both threads are working with Fl_Text_Buffer, they'll need to lock each other out to prevent races and deadlocks. > 1) Is it possible to make callback functions multithreaded? Maybe you can > give some example? The callbacks are triggered by FLTK, so they'll be called only from the main thread. You can start threads yourself if you want from those callbacks. > 2) The "lags"(long-term operations) in my program are unexpected by design > so I don't know in which place to make FL::awake() to give control back to > main thread. Hmm, I think you'll have to figure out where the lags are first. If the lags are because you're doing a 10,000 line insert into the editor's buffer, and the buffer's insert() operation is taking a lot of time doing it, using threads won't be solving that problem, because the entire Fl_Text_Buffer will need to be locked during that time, which means the FLTK thread will need to be on hold. If you have multiple windows each potentially doing operations at the same time, then maybe child threads would be safe to use if they're each working on the different window's Fl_Text_Buffers while the main thread is locked out. The goal is you don't want the FLTK thread (the "GUI" thread, or main thread) to be doing anything with the Fl_Text_Buffer's while your child threads are modifying them. Have to get back to work ;) perhaps someone else can take on the rest of your questions.. _______________________________________________ fltk-dev mailing list fltk-dev@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-dev