Re: XForms: Best way to ...

Steve Lamont (spl@szechuan.ucsd.edu)
Fri, 29 Aug 97 07:40:50 PDT

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> My view is to run the video in the idle_callback. However, when I
> touch the other interface objects, how can I be sure the video code
> in the idle_callback has completed.

The idle callback code basically runs until control is returned to
XForms with a `return' statement. Thus, it is entirely under your
control.

Basically, the idle callback is called as part of the XForms internal
event loop.

The idle callback may not be the best way for you to go on this. If
you're reading from a pipe or other file descriptor, you may want to
use the I/O callback rather than the idle callback. Just register the
file descriptor with XForms and it will call your callback whenever
data are ready for you to process.

> I suspect this is basically a question for TC as I need to know at
> what state the running code in a idle_callback is left when interrupted
> by another XFORMS event. Is it a true interrupt, or does it wait for
> completion of the code in the idle_callback before switching to the
> activated callback for the object? TC?

No, it is not. As discussed above, the return is under your control.

There is a facility for catching signals (fl_add_signal_callback()) in
XForms but this is something different. It catches and logs any
signals registered with it and calls a callback in a safe manner.
Catching signals on your own and processing them with anything other
than setting a flag is unhealthy since you don't know what's been
interrupted with the signal. If it's an X or XForms function and you
try to execute some other X or XForms function, you're going to lose
badly, since X and XForms are not designed to be reentrant.

> I was also thinking of setting and clearing a flag at start end of video
> grab code, and then using this flag in a check_forms loop, but I am still
> wary of having the video code running "on its own" in the idle_callback

This won't work, at least as I understand what you are proposing. If
the idle callback takes over, it will block any interaction until you
return control to XForms.

The idle callback function should only run a fraction of a second, say
up to 300 milliseconds, at a time. Otherwise, interactivity degrades.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/