10.6.2 Using Prolog engines from C
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Multithreaded applications
        • Multithreaded mixed C and Prolog applications
          • Using Prolog engines from C
            • PL_current_engine()
            • PL_create_engine()
            • PL_destroy_engine()
            • PL_set_engine()
            • PL_WITH_ENGINE()
    • Packages
Availability:C-language interface function
int PL_set_engine(PL_engine_t engine, PL_engine_t *old)
Make the calling thread ready to use engine. If old is non-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.