NULL to create a thread
with default attributes. Otherwise it is a pointer to a structure as
defined below. The structure must be fully initialized, including
hidden fields. 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. The function is called with the
thread id (see PL_thread_self())
as argument and must return PL_THREAD_CANCEL_JOINED if the
thread was reclaimed successfully, PL_THREAD_CANCEL_MUST_JOIN
if the thread as cancelled, but must still be joined or
PL_THREAD_CANCEL_FAILED if the request cannot be honoured.
If this function is not present or returns PL_THREAD_CANCEL_FAILED
pthread_cancel() is used. The new thread inherits is properties
from Prolog's main thread. The flags field
defines the following flags:
current_input and current_output
are set to user_input and user_output of the
main thread. Using this flag, these streams are copied from the main
thread. See also the inherited_from option 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 */
char * thread_class; /* Class property of the thread */
} 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.