ThreadId executes Goal as an interrupt at the first opportunity. Defined opportunities are:
sig_atomic
. Currently this only applies
to sig_atomic/1.FALSE
after PL_handle_signals()
returned -1, indicating an exception was raised.SIGUSR2
to the signalled thread while the handler is an
empty function. This causes most blocking system calls to return with EINTR
.
See also the commandline option
--sig-alert. On Windows, PL_handle_signals()
is called when the user processes Windows messages.If one or more signals are queued, the queue is processed. Processing the queue skips signals blocked due to sig_block/1 and stops after the queue does not contain any more non-blocked signals or processing a signal results in an exception. After an exception, other signals remain in the queue and will be processed after unwinding to the matching catch/3. Typically these queued signals will be processed during the Recover goal of the catch/3. Note that sig_atomic/1 may be used to protect the recovery goal.
The thread_signal/2
mechanism is primarily used by the system to insert debugging goals into
the target thread (tspy/1, tbacktrace/1,
etc.) or to interrupt a thread using e.g., thread_signal(Thread,
abort)
. Predicates from library library(thread)
use
signals to stop workers for e.g. concurrent_maplist/2
if some call fails. Applications may use it, typically for similar
purposes such as asynchronously stopping tasks or inspecting the status
of a task. Below we describe the behaviour of thread signalling in more
detail. The following notes apply for
Goal executing in ThreadId