[ Reference Manual | Alphabetic Index ]

# library(threads)

Prolog thread API (ISO/IEC Draft TR 13211-5:2007) [more]

## Predicates

> is_thread(?Term)
>   Succeeds if Term is a DTR-thread alias or thread/engine handle
> message_queue_create(-Queue)
>   Creates a DTR message queue
> message_queue_create(-Queue, ++Options)
>   Creates a DTR message queue
> message_queue_destroy(+Queue)
>   Destroy a DTR message queue
> mutex_create(?Mutex)
>   Creates a mutual exclusion object with alias
> mutex_create(-Mutex, ++Options)
>   Creates a mutual exclusion object
> mutex_destroy(+Mutex)
>   Destroys a mutual exclusion object
> thread_cancel(+Thread)
>   Makes Thread exit at the next opportunity
> thread_create(+Goal)
>   Create a detached DTR-thread with default options
> thread_create(+Goal, -Thread)
>   Create a DTR-thread with default options
> thread_create(+Goal, -Thread, +Options)
>   Create a DTR-thread
> thread_default(?Option)
>   Get default options for thread/engine creation
> thread_detach(+Thread)
>   Thread
> thread_exit(+Term)
>   Exit the executing DTR-thread with status exited(Term)
> thread_get_message(?Message)
>   Wait for and remove a message from the calling DTR-thread's message queue
> thread_get_message(+Queue, ?Message)
>   Wait for and remove a message from Queue
> thread_join(+Thread, -Status)
>   Wait for termination of Thread
> thread_peek_message(-Message)
>   Check for Message in the calling DTR-thread's message queue
> thread_peek_message(+Queue, -Message)
>   Check for Message in Queue
> thread_property(?Thread, ?Property)
>   Enumerates threads and their properties
> thread_self(?Thread)
>   True if Thread is the calling DTR-thread
> thread_send_message(?Message)
>   Sends a message via the calling DTR-thread's message queue
> thread_send_message(+Queue, ?Message)
>   Sends a message via Queue
> thread_set_default(++Option)
>   Set default options for thread/engine creation
> thread_signal(+Thread, +Goal)
>   Makes Thread execute Goal at the next opportunity
> thread_sleep(+Seconds)
>   Suspends the calling thread/engine for Seconds seconds
> with_mutex(+Mutex, +Goal)
>   Equivalent to once(Goal) but with mutual exclusion

## Other Exports

## Description

This library implements most of the functionality described in the Draft Technical Recommendation ISO/IEC DTR 13211-5:2007 'Prolog Multi-threading Support' (http://logtalk.org/plstd/threads.pdf), which is also the basis for multi-threading functionality in a number of Prolog systems (SWI, XSB, YAP). To clarify notation, we will refer to

- this library's 'threads' as DTR-threads
- this library's 'queues' as DTR-queues

Note that this library is just a thin layer on top of ECLiPSe's more general 'engine' functionality. The main differences are:

- DTR-threads are implemented as ECLiPSe engines, and DTR-queues are implemented as ECLiPSe records. While this in principle allows the mixing of ECLiPSe's native engine-API and this library's API, in the interest of readable code, programmers should commit to one of the APIs.
- An ECLiPSe engine can optionally be associated with an operating system thread, while DTR-threads are always associated with an operating system thread.
- An ECLiPSe engine can stop (with success, failure, etc), retain its state, and later be resumed. In contrast, DTR-threads execute a single goal, are terminated as soon as this goal succeeds or fails or exits, and disappear when the thread is joined.
- Although this library implements alias names for DTR-threads and queues, they should be used sparingly because they prevent automatic garbage collection of the named object. For efficiency reasons, only one alias per item is supported.

## About

- Author: Joachim Schimpf
- Copyright © Coninfer Ltd
- Date: $Date: 2017/09/03 00:50:40 $

Generated from threads.eci on 2020-02-26 22:26