[Gambas-user] gb3: how to check if event is pending execution before it triggers

Bruce Bruen bbruen at ...2308...
Sat Mar 17 08:05:40 CET 2012


On Sat, 2012-03-17 at 02:04 -0400, Kevin Fishburne wrote:
> Is there a way to check if an event is going to trigger in advance? 
Not in the known universe.  It would be nice though, Lotto numbers,
stock price changes etc etc :-)

> My startup procedure (GUI.Main) allows two event procedures to trigger, 
> Render.Screen_Draw (SDL) and Network.UDP_Read (UDP socket). When 
> Screen_Draw triggers I need to know if there are pending UDP packets so 
> I can avoid rendering the frame until those pending network events are 
> processed. The logic would look something like this:
> 
> Public Sub Screen_Draw()
>    If [there is data in the socket] Then Return
>    [render a complete frame]
> End
> 
> Basically I need to give processing incoming UDP packets priority over 
> rendering frames since processing the packets is quick but rendering a 
> frame is slow. I only want it to render a frame when there are no 
> incoming UDP packets needing attention. I've been thinking about logical 
> ways to do this, but if there is some inherent GAMBAS way that would be 
> more elegant.
> 
Could you use some global counter to achieve this?
For every UDP packet received, inc the counter and dec it on UDP_Read
(or zero it?)
Then Screen_Draw need only check that the counter is zero.

I don't really know whether this will work for you but from your
description it does sound like a classic semaphore problem. ???

hth
Bruce





More information about the User mailing list