FLTK logo

Re: [fltk.general] Use worker thread to call Fl_Window and Fl_run

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Use worker thread to call Fl_Window and Fl_run Paul Hahn Oct 01, 2020  
 
> The "historical" model for GUI programs is the main process is the GUI handler thread, and if there is significant, potentially blocking activity, it takes place in secondary threads. 

Tho, thinking about it for 5 seconds, I don't see why the GUI thread couldn't be a secondary thread ... 


In my case, GUI processing is in the main thread in each of the processes (parent and forked child), which keeps things happy for normal FLTK run time processing. Messages are handled separately by a secondary (listener) thread on each side. Interprocess communication (IPC) is via the Unix pipe(2) 2-way link (read & write file descriptor pairs) between the processes. Outgoing messages are typically originated from within FLTK callbacks in a non-blocking way. Incoming messages are enqueued by the listener thread on the other end. These messages are interpreted in the main loop on that end via an FLTK idle handler. I take care on both ends to make sure things don't block in ways that might result in a deadlock (livelock). The message queuing and asynchronicty between the processes might slow things down, but in practice, it is fast enough for my purposes, at least on Linux (my only platform).

Actually, in the specific case of my animated "wait window widget", the child process does all the animation graphics, and I modify the above scheme so the launcher (parent process) by default does not have a separate listener thread, but itself blocks waiting for the child to emit "finished" (e.g., which happens when Cancel button is pressed, processing reaches completion, the process dies unexpectedly, etc.).

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/0f04c12e-f227-43c6-98ec-1aacfaff33a7n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.