PublicShow sourcethreadutil.pl -- Interactive thread utilities

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.

Source threads
List currently known threads with their status.
Source join_threads
Join all terminated threads.
Source interactor is det
Source interactor(?Title) is det
Run a Prolog toplevel in another thread with a new console window. If Title is given, this will be used as the window title.
Source thread_run_interactor
Attach a console and run a Prolog toplevel in the current thread.
Source thread_has_console is semidet
True when the calling thread has an attached console.
See also
- attach_console/0
Source attach_console is det
Source attach_console(?Title) is det
Create a new console and make the standard Prolog streams point to it. If not provided, the title is built using the thread id. Does nothing if the current thread already has a console attached.
Source xterm_args(-List) is nondet[multifile]
Multifile and dynamic hook that provides (additional) arguments for the xterm(1) process opened for additional thread consoles. Each solution must bind List to a list of atomic values. All solutions are concatenated using append/2 to form the final argument list.

The defaults set the colors to black-on-light-yellow, enable a scrollbar, set the font using Xft font pattern and prepares the back-arrow key.

Source tspy(:Spec) is det
Source tspy(:Spec, +ThreadId) is det
Trap the graphical debugger on reaching Spec in the specified or any thread.
Source tdebug is det
Source tdebug(+Thread) is det
Enable debug-mode, trapping the graphical debugger on reaching spy-points or errors.
Source tnodebug is det
Source tnodebug(+Thread) is det
Disable debug-mode in all threads or the specified Thread.
Source tbacktrace(+Thread) is det
Source tbacktrace(+Thread, +Options) is det
Print a backtrace for Thread to the stream user_error of the calling thread. This is achieved by inserting an interrupt into Thread using call_in_thread/2. Options:
depth(+MaxFrames)
Number of stack frames to show. Default is the current Prolog flag backtrace_depth or 20.

Other options are passed to get_prolog_backtrace/3.

bug
- call_in_thread/2 may not process the event.
Source tprofile(+Thread) is det
Profile the operation of Thread until the user hits a key.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

Source tdebug(Arg1)
Source tbacktrace(Arg1, Arg2)
Source tnodebug(Arg1)
Source tspy(Arg1, Arg2)
Source interactor(Arg1)
Source attach_console(Arg1)