I am migrating from a version of 1.4 downloaded 2020/3/22 to one downoaded 2022/2/28.
I am now expriencing the following...
My app never gets to the call of fl::run() as it launches a server that listens for receipts of UDP datagrams from another application first. It then loops listening for these.
Previously the FLTK scheduler would still respond to events from FLTK buttons before I call fl::run(). Now it does not.
I have a note in the code to implement the UDP server as a separate thread, but this will require me to understand multi-threading first. Is there a light-weight mechanism in FLTK that I can launch the UDP server and procede to the call of fl::run()?
On 3/2/22 12:07 'pvr...@btinternet.com' via fltk.general wrote:
I am migrating from a version of 1.4 downloaded 2020/3/22 to one downoaded 2022/2/28.
I am now expriencing the following...
My app never gets to the call of fl::run() as it launches a server that listens for receipts of UDP datagrams from another application first. It then loops listening for these.
Previously the FLTK scheduler would still respond to events from FLTK buttons before I call fl::run(). Now it does not.
This described "previous" behavior is technically not possible - unless you used Fl::wait() or something like this that dispatches FLTK events. Fl::run() does this for you in a loop as long as there are open windows.
I have a note in the code to implement the UDP server as a separate thread, but this will require me to understand multi-threading first. Is there a light-weight mechanism in FLTK that I can launch the UDP server and procede to the call of fl::run()?Calling Fl::wait() inside your polling loop will do what you want because this is what Fl::run() would do. You can't use blocking read's though on your UDP server (socket), of course, because this would obviously block calling Fl::wait() as well. Untested pseudo code follows:
int connected = 0;
while (!connected) {
Fl::wait(0.05); // wait 1/20 of a second
if ( poll_udp_socket() ) { // must be unblocking!
// do something
connected = 1;
}
}
return Fl::run();
o
Another way would be to use Fl::add_idle() and run your polling in the idle loop but this is another issue and not as simple as it may sound, maybe.
Thanks Albrecht. I am now happy with the latest 1.4 version (well Monday's at least)On Wednesday, March 2, 2022 at 1:12:19 PM UTC Albrecht Schlosser wrote:Previously the FLTK scheduler would still respond to events from FLTK buttons before I call fl::run(). Now it does not.On 3/2/22 12:07 'pvr...@btinternet.com' via fltk.general wrote:
This described "previous" behavior is technically not possible - unless you used Fl::wait() or something like this that dispatches FLTK events. Fl::run() does this for you in a loop as long as there are open windows.I knpw I played around with using Fl::wait() to get certain stuff to draw. I don't recall changing this as part of the migration.