[ External Interface | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]
Yield control to the C/C++ main program that has invoked ECLiPSe.
The arguments are used for passing data in and out.
- A term.
- A variable.
When ECLiPSe is used as an embedded component within an application
written in C/C++, the ECLiPSe execution is conceptually a thread.
Therefore, a yield-resume control flow model is used.
On the C/C++ side, the ec_resume()/EC_resume() functions pass
control to the ECLiPSe thread, while on the ECLiPSe side, the
yield/2 predicate is used to pass control back.
Data can be passed both ways: the ToC argument of yield/2 is passed
to C/C++ via the second argument of ec_resume()/EC_resume() when it
returns. Similarly a ec_resume()/EC_resume() first argument is
passed to ECLiPSe as the FromC argument of yield/2.
This mechanism is supposed to be used such that an ECLiPSe server
loop is set up, and the host program resumes ECLiPSe repeatedly
to have a request served.
Note that, by default, ECLiPSe is set up as a server which calls
posted goals. This is such a general mechanism that it is often
not necessary to write a special-purpose server loop.
Modes and Determinism
% ECLiPSe server code
// C++ client code
if (EC_resume() == EC_yield)
// create a request
if (EC_resume(request, result) != EC_yield);
// use the result
xget / 3, xset / 3