
yield(+ToC, -FromC)

   Yield control to the C/C++ main program that has invoked ECLiPSe.
The arguments are used for passing data in and out.



Arguments
   ToC                 A term.
   FromC               A variable.

Type
   External Interface

Description
   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
   yield(+, -) is det

Examples
   
    % ECLiPSe server code
    start_server :-
        eclipse_server(dummy).

    eclipse_server(PrevResult) :-
        yield(PrevResult, Request),
        process_request(Request, NewResult),
        eclipse_server(NewResult).


    // C++ client code
    ec_init();
    post_goal("start_server");
    if (EC_resume() == EC_yield)
    {
        for(;;)
        {
	    // create a request
            ...
            if (EC_resume(request, result) != EC_yield);
                break;
            ...
            // use the result
        }
    }





See Also
   xget / 3, xset / 3
