Re: [fltk.coredev] About mixing Fl::awake(Fl_Awake_Handler, void*) and Fl::awake(void*)

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: About mixing Fl::awake(Fl_Awake_Handler, void*) and Fl::awake(void*) Albrecht Schlosser 13:55 Jul 06 top right image
 
On 7/6/21 10:34 PM Bill Spitzak wrote:
I'm pretty certain that Fl::awake(void* message) is exactly the same as Fl::awake(F, message) where F is a "Fl_Awake_Handler" that is internal to fltk. Basically it does not conflict or have any problems different from any other implementation of an Fl_Awake_Handler. This one just stores message in a static variable.

The static variable is the problem, independent of any interaction or incompatibility with the other form of Fl::awake(). Since there is only one static variable callling Fl::thread_message() later in user code can only retrieve the last value assigned to this variable. Hence Fl::awake(void* message) is IMHO always unreliable unless you know that messages are queued infrequently, i.e. less than can be handled by events. A user moving the mouse permanently would likely lead to an "event overflow" dropping messages, whereas Fl::awake(F, message) queues all messages so no message can ever be lost.


On Mon, Jul 5, 2021 at 12:33 PM Albrecht Schlosser <...> wrote:

Despite the warning in the docs I believe that using Fl::awake(Fl_Awake_Handler cb, void* userdata) is always "on the safe side". As Ian wrote already, the warning may be from an older part of the docs.

I believe the warning is platform independent and the part "on some platforms" can probably be removed. I would add that Fl::awake(void* message) is always kinda unreliable but using Fl::awake(Fl_Awake_Handler cb, void* userdata) is always reliable as long as you don't use the same userdata pointer during the lifetime of such an Fl::awake() request. With "lifetime" I mean the time from writing to the memory pointed to by userdata until it is processed by the awake handler. This is the essential part.

The docs of Fl::awake(void* message) say: "The default message handler saves the last message which can be accessed using the Fl::thread_message() function." This means that there is only one (likely static) storage location which will be overwritten if you call Fl::awake(void* message) more frequently than the awake call can be serviced. This will drop all intermediate messages and only the last message can ever be retrieved by the user program with Fl::thread_message(). Hence, the user program is responsible for not calling Fl::awake(void* message) more often than can be serviced by the FLTK main loop.

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/74a7eec6-89d9-3d14-4005-755cfca32956%40online.de.
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]New Message | Reply ]Next Message ]
 
 

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