This library provides utilities that are primarily intended for interactive usage in a threaded Prolog environment. It allows for inspecting threads, manage I/O of background threads (depending on the environment) and manipulating the debug status of threads.
once(Goal).
Note that this is in the thread user utilities as this is not something
that should be used by normal applications. Notably, this may
deadlock if the current thread requires input from some other
thread to complete Goal or one of the stopped threads has a
lock.
Options:
true (default false), also stop threads
created with the debug(false) option.
class property of a thread set by thread_create/3
or set_thread/2.
This implies loading the graphical tracer and switching the thread to
debug mode using debug/0.
New threads created inherit their debug mode from the thread that
created them.
Thread classes have been introduced in SWI-Prolog 10.0.2/10.1.5. This
allows for more selective debugging as well as ensuring debugging works
in newly created threads. For example, the HTTP server creates all its worker
threads in the class http. Using query below, we
reliable make sure spy points are trapped in HTTP handler threads,
regardless of whether the worker existed or is lazily created and
regardless of whether the user switched to
nodebug mode while tracing a previous event (see
debug_reset_from_class/0).
?- tdebug(http).
user_error
of the calling thread. This is achieved by inserting an interrupt into
Thread using call_in_thread/2. Options:
backtrace_depth
or 20.
Other options are passed to get_prolog_backtrace/3.