The trivial-main-thread Reference Manual

This is the trivial-main-thread Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sat Dec 03 23:33:18 2022 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 trivial-main-thread

Compatibility library to run things in the main thread.

Maintainer

Nicolas Hafner <>

Author

Nicolas Hafner <>

Home Page

https://Shinmera.github.io/trivial-main-thread/

Source Control

(GIT https://github.com/Shinmera/trivial-main-thread.git)

Bug Tracker

https://github.com/Shinmera/trivial-main-thread/issues

License

zlib

Version

1.0.0

Dependencies
  • trivial-features (system).
  • bordeaux-threads (system).
  • simple-tasks (system).
Source

trivial-main-thread.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 trivial-main-thread/trivial-main-thread.asd

Source

trivial-main-thread.asd.

Parent Component

trivial-main-thread (system).

ASDF Systems

trivial-main-thread.


3.1.2 trivial-main-thread/package.lisp

Source

trivial-main-thread.asd.

Parent Component

trivial-main-thread (system).

Packages

trivial-main-thread.


3.1.3 trivial-main-thread/main-thread.lisp

Dependency

package.lisp (file).

Source

trivial-main-thread.asd.

Parent Component

trivial-main-thread (system).

Public Interface
Internals

3.1.4 trivial-main-thread/documentation.lisp

Dependency

main-thread.lisp (file).

Source

trivial-main-thread.asd.

Parent Component

trivial-main-thread (system).

Internals

setdocs (macro).


4 Packages

Packages are listed by definition order.


4.1 trivial-main-thread

Source

package.lisp.

Nicknames
  • tmt
  • org.shirakumo.trivial-main-thread
Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *main-thread*

Holds the main thread.

Package

trivial-main-thread.

Source

main-thread.lisp.

Special Variable: *runner*

Holds the runner object to be set into the main thread.

See SIMPLE-TASKS:RUNNER

Package

trivial-main-thread.

Source

main-thread.lisp.


5.1.2 Macros

Macro: with-body-in-main-thread ((&key blocking runner) &body body)

Evaluate the BODY in the main thread. This always calls ENSURE-MAIN-RUNNER-STARTED.

See CALL-IN-MAIN-THREAD

Package

trivial-main-thread.

Source

main-thread.lisp.


5.1.3 Ordinary functions

Function: call-in-main-thread (function &key blocking runner)

Call FUNCTION in the main thread.
This always calls ENSURE-MAIN-RUNNER-STARTED.

If BLOCKING is non-NIL, the current thread is blocked until the function has finished running. The function’s return values are returned. Otherwise, the task created to call the function is returned.

See SIMPLE-TASKS:CALL-AS-TASK

Package

trivial-main-thread.

Source

main-thread.lisp.

Function: ensure-main-runner (&key main-thread runner)

Ensure that the main thread runner is indeed running.

If the MAIN-THREAD is EQL to BT:CURRENT-THREAD, then the RUNNER is CHANGE-CLASSed into SIMPLE-TASK:RUNNER. This runner class does not use threading and instead directly executes the tasks. If we did not do this, situations where the main thread is the currently evaluating thread, we would block it forever, and thus stop it from ever reaching any task scheduling calls.

Package

trivial-main-thread.

Source

main-thread.lisp.

Function: ensure-main-runner-started (&key main-thread runner)

Ensure that the main thread runner is indeed started.
This calls ENSURE-MAIN-RUNNER and then sleeps until the runner reports itself as running.

Package

trivial-main-thread.

Source

main-thread.lisp.

Function: find-main-thread ()

Attempts to find the main thread (thread 0) of the implementation.

If no implementation specific handling is implemented, the last thread in the list of threads reported by BT:ALL-THREADS is primitively chosen.

Package

trivial-main-thread.

Source

main-thread.lisp.

Function: schedule-task (task &optional runner)

Schedule TASK to be run on the main thread runner. This always calls ENSURE-MAIN-RUNNER-STARTED.

See SIMPLE-TASKS:SCHEDULE-TASK

Package

trivial-main-thread.

Source

main-thread.lisp.

Function: start-main-runner (&key main-thread runner)

Starts the runner in the main thread.

If a runner or main-thread is passed explicitly, *RUNNER* and *MAIN-THREAD* are set to those values respectively.

See SIMPLE-TASKS:START-RUNNER
See SWAP-MAIN-THREAD

Package

trivial-main-thread.

Source

main-thread.lisp.

Function: stop-main-runner (&key main-thread runner)

Stops the runner in the main thread, allowing it to continue.

This will destroy any sidestepping thread that might have been created by SWAP-THREAD.

Package

trivial-main-thread.

Source

main-thread.lisp.

Function: swap-main-thread (new-function &optional main-thread)

Swaps the main thread for our own FUNCTION.

If the implementation uses the main thread for vital tasks, this function tries to ensure that these vital tasks are continued in a new thread instead.

If the MAIN-THREAD is EQL to BT:CURRENT-THREAD, then the FUNCTION is simply called.

Package

trivial-main-thread.

Source

main-thread.lisp.


5.2 Internals


5.2.1 Macros

Macro: %ensure-mt (var)
Package

trivial-main-thread.

Source

main-thread.lisp.

Macro: setdocs (&body pairs)
Package

trivial-main-thread.

Source

documentation.lisp.


5.2.2 Ordinary functions

Function: runner-starter (runner)
Package

trivial-main-thread.

Source

main-thread.lisp.


Appendix A Indexes


A.1 Concepts