10.6.2 Pooling Prolog engines (many-to-many)
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Multithreaded applications
        • Multithreaded mixed C and Prolog applications
          • Pooling Prolog engines (many-to-many)
            • PL_create_engine()
            • PL_destroy_engine()
            • PL_set_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.

In the single-threaded version this call only succeeds if engine refers to the main engine.