Page 1 of 1

"send on signal"

Posted: Tue Sep 18, 2018 7:11 am
by pderocco
One limitation of the desktop externals interface is the inability for an asynchronous OS callback to invoke a message in LiveCode. The iOS externals interface seems to have a "post message" type of function that the external can call, and it would be nice if the desktop externals interface did too, but it blocks until the engine is at a point where it can accept the message, which might be a problem.

Where I run up against this is in receiving MIDI: I have to poll my external with a timer, using something like

Code: Select all

send TimerTick to stack "Main" in 5 milliseconds
But this demonstrates that the LiveCode desktop engine can indeed respond to an asynchronous event: a timer. I'm wondering if it wouldn't be fairly easy to add something like:

Code: Select all

send ReadInput to stack "Main" on signal 1
where 1 is just an arbitrary integer that allows multiple distinct signals to be handled. The external interface would simply need a function that sends a signal with an int parameter.

The two could be combined, for implementing a timed wait:

Code: Select all

send ReadResponse to stack "Main" on signal 1 or in 5 milliseconds
where the handler, in this case ReadResponse, would get a boolean parameter that indicates whether the input was received or the time limit was reached.

This sort of feature would eliminate a lot of timed polling, and result in faster response times to input events.