TclEvent(3)

CLASS
tcl.lang.TclEvent -- Subclass from this abstract base class to create event handlers.

METHODS

abstract int processEvent(int flags)

synchronized final void sync()

ARGUMENTS
Same as flags passed to the doOneEvent method of the Notifier class.

DESCRIPTION
The TclEvent class is used to schedule events to be processed in a Jacl Notifier. Usually, an event-driven Jacl application consists of one "Notifier Thread" and one or more "Event Detection Threads". When an Event Detection Thread detects an event, it puts an instance of TclEvent on the queue of the Notifier. Then, when the Notifier Thread is ready to process events (i.e., when the doOneEvent method of the Notifier class is invoked), it invokes the processEvent method of the TclEvent instances in the order they appear in the Notifier's event queue.

processEvent
    When processEvent is called, it should determine whether the event can be processed right away (possibly based on the settings of the flags parameter). If the event cannot be processed yet, this method returns 0, in which case the Notifier will leave the event in the event queue and defer its processing to some later time. Otherwise, this method should process the event and return 1, in which case the Notifier will remove the event from the event queue.

sync
    Usually, TclEvent instances are processed asynchronously. If synchronous processing is desired, an Event Detection Thread can call the sync method, which waits until the event is processed by the Notifier. The TclEvent must be in the event queue before its sync method can be invoked, otherwise a TclRuntimeError will be generated.

EQUIVALENT C FUNCTIONS
Tcl_EventProc, Tcl_ServiceAll

SEE ALSO
Notifier, Interp, TclRuntimeError, IdleHandler, TimerHandler

KEYWORDS
event, event queue, thread, event sources, event detection