In this model Prolog engines live as entities that are independent from threads. If a thread needs to call Prolog it takes one of the engines from the pool and returns the engine when done. This model is suitable in the following identified cases:
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.
In the single-threaded version this call only succeeds if engine refers to the main engine.