Availability:C-language interface function
NULL to create a thread
with default attributes. Otherwise it is a pointer to a structure with
the definition below. For any field with value‘0’, the
default is used. The
cancel field may be filled with a pointer to a function
that is called when PL_cleanup()
terminates the running Prolog engines. If this function is not present
or returns FALSE pthread_cancel() is used. The new
thread inherits is properties from Prolog's main thread.
The flags field defines the following flags:
- PL_THREAD_NO_DEBUG
- If this flag is present, the thread starts in normal no-debug status. By default, the debug status is inherited from the main thread.
- PL_THREAD_NOT_DETACHED
- By default the new thread is created in detached mode. With this flag it is created normally, allowing Prolog to join the thread.
- PL_THREAD_CUR_STREAMS
- By default the
current_inputandcurrent_outputare set touser_inputanduser_outputof the main thread. Using this flag, these streams are copied from the main thread. See also theinherited_fromoption of thread_create/3.
typedef struct
{ size_t stack_limit; /* Total stack limit (bytes) */
size_t table_space; /* Total tabling space limit (bytes) */
char * alias; /* alias name */
int (*cancel)(int thread); /* cancel function */
intptr_t flags; /* PL_THREAD_* flags */
size_t max_queue_size; /* Max size of associated queue */
} PL_thread_attr_t;
The structure may be destroyed after PL_thread_attach_engine() has returned. On success it returns the Prolog identifier for the thread (as returned by PL_thread_self()). If an error occurs, -1 is returned. If this Prolog is not compiled for multithreading, -2 is returned.