AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
invokeLater (Callable funct, ...) yoix.awt
invokeLater (Pointer ptr, ...)  
 
Arranges to call funct from the thread that Java is using to dispatch AWT events after the events pending at the time of the invokeLater call are processed. Everything that follows funct in the invokeLater call are arguments that will be passed to funct when it is executed. invokeLater aborts with a badcall error if funct requires a different number of arguments than were actually supplied in the invokeLater call.

If the first argument is a Pointer then *ptr must be Callable and it will be the Function or Builtin that invokeLater executes. In addition, when *ptr is a Function and ptr is a Dictionary or any other object that associates names with values, then ptr is used as the function's local context. In other words, ptr will be used to resolve this and it will also be searched immediately before the function's global context.
 
 Example:   The program
import yoix.*.*;

VM.exitmodel = 0;      // so main thread does not exit

Button b = {
    actionPerformed(Event e) {
        printf("actionPerformed: sleep for 1 second\n");
        sleep(1);
    }

    invocationRun(Event e) {
        printf("invocationRun: sleep for 1 second\n");
        sleep(1);
    }
};

ActionEvent ae = {
    String id = "actionPerformed";
};

InvocationEvent ie = {
    String id = "invocationRun";
};

f(double secs, int quit) {
    printf("invokeLater: sleep for %.1g seconds\n", secs);
    sleep(secs);
    if (quit)
        exit(0);
}

postEvent(ae, b);
postEvent(ie, b);
invokeLater(f, 2.1, FALSE);
postEvent(ae, b);
invokeLater(f, 1.5, TRUE);

printf("Main thread is done\n");
prints something like
Main thread is done
actionPerformed: sleep for 1 second
invocationRun: sleep for 1 second
invokeLater: sleep for 2.1 seconds
actionPerformed: sleep for 1 second
invokeLater: sleep for 1.5 seconds
on standard output. The messages that result from the invokeLater and postEvent calls are generated by the thread used to dispatch AWT events, so their order is fixed, but the message generated by the main thread could slip in anywhere.
 
 Return:   none
 
 See Also:   ActionEvent, AdjustmentEvent, CaretEvent, ChangeEvent, ComponentEvent, DragGestureEvent, DragSourceEvent, DropTargetEvent, Event, FocusEvent, HyperlinkEvent, InvocationEvent, isDispatchThread, ItemEvent, KeyEvent, ListSelectionEvent, MouseEvent, MouseWheelEvent, PaintEvent, postEvent, TextEvent, TreeSelectionEvent, WindowEvent

 

Yoix is a registered trademark of AT&T Intellectual Property.