Did you know ... | Search Documentation: |
![]() | Using Prolog engines from C |
Prolog engines live as entities that are independent from threads.
They are always supported in the multi-threaded version and may be
enabled in the single threaded version by providing -DENGINES=ON
during the
cmake configuration. Multiple threads may use a pool of engines
for handling calls to Prolog. A single thread may use multiple engines
to achieve coroutining. Engines are suitable in the following
identified cases:
NULL
if
the thread has no Prolog engine.
In the single-threaded version this call always returns NULL
,
indicating failure.
TRUE
, on failure the
return value is FALSE
.NULL
the current engine associated with the calling
thread is stored at the given location. If engine equals
PL_ENGINE_MAIN
the initial engine is attached to the
calling thread. If engine is PL_ENGINE_CURRENT
the engine is not changed. This can be used to query the current engine.
This call returns
PL_ENGINE_SET
if the engine was switched successfully,
PL_ENGINE_INVAL
if engine is not a valid engine
handle and
PL_ENGINE_INUSE
if the engine is currently in use by
another thread.
Engines can be changed at any time. For example, it is allowed to
select an engine to initiate a Prolog goal, detach it and at a later
moment execute the goal from another thread. Note, however, that the
term_t
, qid_t
and fid_t
types are
interpreted relative to the engine for which they are created. Behaviour
when passing one of these types from one engine to another is undefined.
The engine to which a query belongs can be requested using PL_query_engine()
In versions that do not support engines this call only succeeds if engine refers to the main engine.
break
to terminate the body
early. The user may not use return
. Using return
does not reset the old engine.