The control flow between Tcl and ECLiPSe is conceptually thread-based. An ECLiPSe goal is executed by using the ec_rpc mechanism. The goal is posted from Tcl, and control is transferred automatically to ECLiPSe to allow the goal to be executed. Control can also be explicitly transferred to ECLiPSe using ec_resume. Furthermore, handler goals can be implicitly invoked on I/O operations on queues (this is described in more detail in section 5.5, with implicit transfer of control.
The related commands are the following:
Unlike ec_resume, calls to ec_rpc can be nested and can be used from within Tcl queue event handlers.
If no format argument is given, the goal is assumed to be in ECLiPSe syntax. If a format argument is provided, the ECLiPSe goal is constructed from goal and format, according to the conversion rules explained in section 5.8.
On success, ec_rpc returns the (possibly more instantiated) goal as a Tcl data structure, otherwise "fail" or "throw" respectively.
This is the recommended way of executing ECLiPSe code from Tcl, and passing the results back (via output arguments) to Tcl.
If the async parameter is 1 (default 0), the ECLiPSe execution is resumed in a separate thread, provided this is supported by the operating system. The effect of this is that Tcl/Tk events can still be handled while ECLiPSe is running, so the GUI does not freeze during computation. However, only one ECLiPSe thread can be running at any time, so before doing another call to ec_resume, ec_handle_events or ec_rpc one should use ec_running to check whether there is not a thread still running.