Looking for a "wait until x or timeout" design pattern..

Scott Rossi scott at tactilemedia.com
Sat Jan 28 05:04:04 EST 2012


You might try:

  wait 30 millisecs with messages

Regards,

Scott Rossi
Creative Director
Tactile Media, UX Design



Recently, Ken Corey wrote:

> I've been working on a pinch library for a week or so, and I have
> complained about the jerkiness. I am thinking that the problem is that
> it's /too/ repsonsive.
> 
> The instant one touch moves, it's causing the pinchMove event to be
> generated.  This is fine if nothing else truly has moved, but if the two
> move events are sent back to back, they should both be handled before
> sending a pinchMove message...not two different pinchMove events.
> 
> The pinchMove event should only be sent once the status of all the
> touches have been updated...but of course, we have no guarantee that
> there's a touchMove coming for each point, nor the order in which they
> will come...
> 
> So, in pseudo code, what I'd like to do is:
> 
> on touchMove i,x,y
>    store x,y into positionArray[i]  -- update the postition for a touch
> 
>    wait until (got touch events from all touches) or \
> (30 milliseconds have passed)
> 
>    pinchMove blah,blah,blah
> end touchMove
> 
> But the wait command seems to either wait 100 milliseconds or wait until
> <cond>, but not both.
> 
> Then I thought to provide a timeout with a 'send "timeout" in xx
> milliseconds', but cancel it if we got events on all touches first.
> Couldn't see how to cancel a pending send.
> 
> I guess I could break my timeout period down and do a series of shorter
> waits (sort of slow polling), with a fall-through at the end of the timeout.
> 
> Also, all other events still need to be handled in the normal
> way...can't lock the application for those 30 seconds.
> 
> Thoughts?
> 
> -Ken
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 








More information about the use-livecode mailing list