Registers for peer multitasking, and setup the (optional) multitask handlers.
There handlers can be specified: a) start, invoked at the start of a
multitasking phase; b) end, invoked at the end of a multitasking
phase, and c) interact, invoked at other times when the peer is
given control during a multitasking phase. Multitask handlers
is a list specifying the handlers, where each handler is specified
as two list elements of the form: type name,
where type is either start, end or interact, and
name is the name of the user defined handler. For example:
ec_multi:peer_register [list interact tkecl:multi_interact_handler
start tkecl:multi_start_handler end tkecl:multi_end_handler]
When control is handed over to the peer during a peer multitasking
phase, the appropriate handler (if defined) is invoked. When the
handler returns, control is handed back to ECLiPSe (and passed
to the next multitasking peer). Note
that events are not processed while the peer does not have control.
The Tcl command update is therefore called each time the peer
is given control, to allow any accumulated events to be processed.
As long as the peer
is given control frequently enough, then any interactions with the
peer would appear to be continuous.
The handlers are invoked with the `type' of the multitasking phase
supplied as the first argument. This will for example allow the
start handler to determine if it is interested in this multitasking
phase. They can also set one of the following return codes:
-
continue
- indicates that the peer wants to continue the multitasking
phase. In particular, this should be returned by the start handler if it is
interested in the multitasking phase. Note that the multitasking phase is
not guaranteed to continue, as it can be terminated by another
multitasking peer.
- terminate
- indicates the termination of a multitasking phase. The
multitasking phase will enter the end phase, where the end handlers
will be invoked once per peer before the multitasking phase finishes.
For example, here is the start handler used in the Tk development
tools:
proc tkecl:multi_start_handler {type} {
switch $type {
tracer {
# multitasking phase is `tracer'
# only do handling of port if the tracer window exists
if [winfo exists .ec_tools.ec_tracer] {
tkecl:handle_tracer_port_start
set of_interest continue
}
}
default {
set of_interest no
# do nothing
}
}
return $of_interest
}
An error is raised if this procedure is called while the peer is already
registered for multitasking.