The pcall Reference Manual

This is the pcall Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 17:31:45 2024 GMT+0.

Table of Contents


1 Systems

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


1.1 pcall

Dependencies
Source

pcall.asd.

Child Components

1.2 pcall-queue

Dependency

bordeaux-threads (system).

Source

pcall-queue.asd.

Child Component

queue.lisp (file).


2 Files

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


2.1 Lisp


2.1.1 pcall/pcall.asd

Source

pcall.asd.

Parent Component

pcall (system).

ASDF Systems

pcall.


2.1.2 pcall-queue/pcall-queue.asd

Source

pcall-queue.asd.

Parent Component

pcall-queue (system).

ASDF Systems

pcall-queue.


2.1.3 pcall/package.lisp

Source

pcall.asd.

Parent Component

pcall (system).

Packages

pcall.


2.1.4 pcall/task.lisp

Dependency

package.lisp (file).

Source

pcall.asd.

Parent Component

pcall (system).

Public Interface
Internals

2.1.5 pcall/pool.lisp

Dependency

task.lisp (file).

Source

pcall.asd.

Parent Component

pcall (system).

Public Interface
Internals

2.1.6 pcall/pcall.lisp

Dependencies
Source

pcall.asd.

Parent Component

pcall (system).

Public Interface

2.1.7 pcall-queue/queue.lisp

Source

pcall-queue.asd.

Parent Component

pcall-queue (system).

Packages

pcall-queue.

Public Interface
Internals

3 Packages

Packages are listed by definition order.


3.1 pcall

Source

package.lisp.

Use List
Public Interface
Internals

3.2 pcall-queue

Source

queue.lisp.

Use List
  • bordeaux-threads.
  • common-lisp.
Used By List

pcall.

Public Interface
Internals

4 Definitions

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


4.1 Public Interface


4.1.1 Macros

Macro: pexec (&body body)

Shorthand for pcall.

Package

pcall.

Source

pcall.lisp.

Macro: plet ((&rest bindings) &body body)
Package

pcall.

Source

pcall.lisp.

Macro: with-local-thread-pool ((&key size on-unwind worker-environment) &body body)

Run body with a fresh thread pool. If on-unwind is :wait, it will wait for all tasks to finish before returning. If it is :leave, the form will return while threads are still working. If it is :stop or :destroy, the threads will be stopped at the end of the body. With :stop, they will first finish their current task (if any), with :destroy, they will be brutally destroyed and might leak resources, leave stuff in inconsistent state, etc.

Package

pcall.

Source

pool.lisp.


4.1.2 Ordinary functions

Function: done-p (task)
Package

pcall.

Source

task.lisp.

Function: finish-tasks ()
Package

pcall.

Source

pool.lisp.

Function: join (task)

Join a task, meaning stop execution of the current thread until the result of the task is available, and then return this result. When this is called on a task that no thread is currently working on, the current thread executes the task directly.

Package

pcall.

Source

task.lisp.

Function: make-queue ()

Create an empty queue.

Package

pcall-queue.

Source

queue.lisp.

Function: pcall (thunk)

Call a thunk in parallel. Returns a task that can be joined. When an exclusive is given, the task will only run when no other tasks with that exclusive are running.

Package

pcall.

Source

pcall.lisp.

Function: queue-empty-p (queue)

Test whether a queue is empty.

Package

pcall-queue.

Source

queue.lisp.

Function: queue-length (queue)

Find the length of a queue.

Package

pcall-queue.

Source

queue.lisp.

Function: queue-pop (queue)

Pop an element from the front of a queue. Returns immediately, returning nil if the queue is empty, and a second value indicating whether anything was popped.

Package

pcall-queue.

Source

queue.lisp.

Function: queue-push (elt queue)

Push an element onto the back of a queue.

Package

pcall-queue.

Source

queue.lisp.

Function: queue-wait (queue)

Pop an element from the front of a queue. Causes a blocking wait when no elements are available.

Package

pcall-queue.

Source

queue.lisp.

Function: select-one (&rest tasks)

Returns the first task that can be joined without blocking.

Package

pcall.

Source

task.lisp.

Function: set-worker-environment (wrapper)
Package

pcall.

Source

pool.lisp.

Function: thread-pool-size ()
Package

pcall.

Source

pool.lisp.

Function: (setf thread-pool-size) ()
Package

pcall.

Source

pool.lisp.


4.2 Internals


4.2.1 Special variables

Special Variable: *pool*
Package

pcall.

Source

pool.lisp.


4.2.2 Ordinary functions

Function: audit-thread-pool ()

Make sure the thread pool holds the correct amount of live threads.

Package

pcall.

Source

pool.lisp.

Function: copy-node (instance)
Package

pcall-queue.

Source

queue.lisp.

Function: copy-pool (instance)
Package

pcall.

Source

pool.lisp.

Function: execute-task (task)

Execute a task, and store the result or error in the task object. When a task’s status is not :free, that means the joiner has already started executing it, so this thread should leave it alone.

Package

pcall.

Source

task.lisp.

Function: make-node (&key val next prev)
Package

pcall-queue.

Source

queue.lisp.

Function: make-pool (&key threads size lock env queue)
Package

pcall.

Source

pool.lisp.

Reader: node-next (instance)
Writer: (setf node-next) (instance)
Package

pcall-queue.

Source

queue.lisp.

Target Slot

next.

Function: node-p (object)
Package

pcall-queue.

Source

queue.lisp.

Reader: node-prev (instance)
Writer: (setf node-prev) (instance)
Package

pcall-queue.

Source

queue.lisp.

Target Slot

prev.

Reader: node-val (instance)
Writer: (setf node-val) (instance)
Package

pcall-queue.

Source

queue.lisp.

Target Slot

val.

Reader: pool-env (instance)
Writer: (setf pool-env) (instance)
Package

pcall.

Source

pool.lisp.

Target Slot

env.

Reader: pool-lock (instance)
Writer: (setf pool-lock) (instance)
Package

pcall.

Source

pool.lisp.

Target Slot

lock.

Function: pool-p (object)
Package

pcall.

Source

pool.lisp.

Reader: pool-queue (instance)
Writer: (setf pool-queue) (instance)
Package

pcall.

Source

pool.lisp.

Target Slot

queue.

Reader: pool-size (instance)
Writer: (setf pool-size) (instance)
Package

pcall.

Source

pool.lisp.

Target Slot

size.

Reader: pool-threads (instance)
Writer: (setf pool-threads) (instance)
Package

pcall.

Source

pool.lisp.

Target Slot

threads.

Function: queue-do-pop (queue)
Package

pcall-queue.

Source

queue.lisp.

Function: spawn-thread (pool)
Package

pcall.

Source

pool.lisp.

Function: stop-thread (thread at-once-p)
Package

pcall.

Source

pool.lisp.

Function: with-locks (locks thunk)
Package

pcall.

Source

task.lisp.

Function: worker-thread (queue)

The code running inside the pooled threads. Repeatedly tries to take a task from the queue, and handles it.

Package

pcall.

Source

pool.lisp.


4.2.3 Generic functions

Generic Reader: queue-back (object)
Package

pcall-queue.

Methods
Reader Method: queue-back ((queue queue))

automatically generated reader method

Source

queue.lisp.

Target Slot

back.

Generic Writer: (setf queue-back) (object)
Package

pcall-queue.

Methods
Writer Method: (setf queue-back) ((queue queue))

automatically generated writer method

Source

queue.lisp.

Target Slot

back.

Generic Reader: queue-condition (object)
Package

pcall-queue.

Methods
Reader Method: queue-condition ((queue queue))

automatically generated reader method

Source

queue.lisp.

Target Slot

condition.

Generic Reader: queue-front (object)
Package

pcall-queue.

Methods
Reader Method: queue-front ((queue queue))

automatically generated reader method

Source

queue.lisp.

Target Slot

front.

Generic Writer: (setf queue-front) (object)
Package

pcall-queue.

Methods
Writer Method: (setf queue-front) ((queue queue))

automatically generated writer method

Source

queue.lisp.

Target Slot

front.

Generic Reader: queue-lock (object)
Package

pcall-queue.

Methods
Reader Method: queue-lock ((queue queue))

automatically generated reader method

Source

queue.lisp.

Target Slot

lock.

Generic Reader: stop-at-once-p (condition)
Package

pcall.

Methods
Reader Method: stop-at-once-p ((condition stop-running))
Source

pool.lisp.

Target Slot

at-once-p.

Generic Reader: task-error (object)
Package

pcall.

Methods
Reader Method: task-error ((task task))

automatically generated reader method

Source

task.lisp.

Target Slot

error.

Generic Writer: (setf task-error) (object)
Package

pcall.

Methods
Writer Method: (setf task-error) ((task task))

automatically generated writer method

Source

task.lisp.

Target Slot

error.

Generic Reader: task-lock (object)
Package

pcall.

Methods
Reader Method: task-lock ((task task))

automatically generated reader method

Source

task.lisp.

Target Slot

lock.

Generic Reader: task-status (object)
Package

pcall.

Methods
Reader Method: task-status ((task task))

automatically generated reader method

Source

task.lisp.

Target Slot

status.

Generic Writer: (setf task-status) (object)
Package

pcall.

Methods
Writer Method: (setf task-status) ((task task))

automatically generated writer method

Source

task.lisp.

Target Slot

status.

Generic Reader: task-thunk (object)
Package

pcall.

Methods
Reader Method: task-thunk ((task task))

automatically generated reader method

Source

task.lisp.

Target Slot

thunk.

Generic Reader: task-values (object)
Package

pcall.

Methods
Reader Method: task-values ((task task))

automatically generated reader method

Source

task.lisp.

Target Slot

values.

Generic Writer: (setf task-values) (object)
Package

pcall.

Methods
Writer Method: (setf task-values) ((task task))

automatically generated writer method

Source

task.lisp.

Target Slot

values.

Generic Reader: task-wait-locks (object)
Package

pcall.

Methods
Reader Method: task-wait-locks ((task task))

automatically generated reader method

Source

task.lisp.

Target Slot

wait-locks.

Generic Writer: (setf task-wait-locks) (object)
Package

pcall.

Methods
Writer Method: (setf task-wait-locks) ((task task))

automatically generated writer method

Source

task.lisp.

Target Slot

wait-locks.

Generic Reader: task-waiting (object)
Package

pcall.

Methods
Reader Method: task-waiting ((task task))

automatically generated reader method

Source

task.lisp.

Target Slot

waiting.

Generic Writer: (setf task-waiting) (object)
Package

pcall.

Methods
Writer Method: (setf task-waiting) ((task task))

automatically generated writer method

Source

task.lisp.

Target Slot

waiting.


4.2.4 Conditions

Condition: stop-running
Package

pcall.

Source

pool.lisp.

Direct superclasses

condition.

Direct methods

stop-at-once-p.

Direct slots
Slot: at-once-p
Initargs

:at-once-p

Readers

stop-at-once-p.

Writers

This slot is read-only.


4.2.5 Structures

Structure: node
Package

pcall-queue.

Source

queue.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: val
Readers

node-val.

Writers

(setf node-val).

Slot: next
Readers

node-next.

Writers

(setf node-next).

Slot: prev
Readers

node-prev.

Writers

(setf node-prev).

Structure: pool
Package

pcall.

Source

pool.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: threads
Readers

pool-threads.

Writers

(setf pool-threads).

Slot: size
Initform

3

Readers

pool-size.

Writers

(setf pool-size).

Slot: lock
Package

bordeaux-threads.

Initform

(bordeaux-threads:make-lock)

Readers

pool-lock.

Writers

(setf pool-lock).

Slot: env
Readers

pool-env.

Writers

(setf pool-env).

Slot: queue
Initform

(pcall-queue:make-queue)

Readers

pool-queue.

Writers

(setf pool-queue).


4.2.6 Classes

Class: queue
Package

pcall-queue.

Source

queue.lisp.

Direct methods
Direct slots
Slot: lock
Package

bordeaux-threads.

Initform

(bordeaux-threads:make-lock)

Readers

queue-lock.

Writers

This slot is read-only.

Slot: condition
Package

common-lisp.

Initform

(bordeaux-threads:make-condition-variable)

Readers

queue-condition.

Writers

This slot is read-only.

Slot: front
Readers

queue-front.

Writers

(setf queue-front).

Slot: back
Readers

queue-back.

Writers

(setf queue-back).

Class: task

A task is a piece of code that is scheduled to run in the thread pool.

Package

pcall.

Source

task.lisp.

Direct methods
Direct slots
Slot: thunk
Initargs

:thunk

Readers

task-thunk.

Writers

This slot is read-only.

Slot: error
Package

common-lisp.

Readers

task-error.

Writers

(setf task-error).

Slot: values
Package

common-lisp.

Readers

task-values.

Writers

(setf task-values).

Slot: lock
Package

bordeaux-threads.

Initform

(bordeaux-threads:make-lock)

Readers

task-lock.

Writers

This slot is read-only.

Slot: wait-locks
Readers

task-wait-locks.

Writers

(setf task-wait-locks).

Slot: status
Initform

:free

Readers

task-status.

Writers

(setf task-status).

Slot: waiting
Readers

task-waiting.

Writers

(setf task-waiting).


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
A   C   D   E   F   G   J   M   N   P   Q   S   T   W  
Index Entry  Section

(
(setf node-next): Private ordinary functions
(setf node-prev): Private ordinary functions
(setf node-val): Private ordinary functions
(setf pool-env): Private ordinary functions
(setf pool-lock): Private ordinary functions
(setf pool-queue): Private ordinary functions
(setf pool-size): Private ordinary functions
(setf pool-threads): Private ordinary functions
(setf queue-back): Private generic functions
(setf queue-back): Private generic functions
(setf queue-front): Private generic functions
(setf queue-front): Private generic functions
(setf task-error): Private generic functions
(setf task-error): Private generic functions
(setf task-status): Private generic functions
(setf task-status): Private generic functions
(setf task-values): Private generic functions
(setf task-values): Private generic functions
(setf task-wait-locks): Private generic functions
(setf task-wait-locks): Private generic functions
(setf task-waiting): Private generic functions
(setf task-waiting): Private generic functions
(setf thread-pool-size): Public ordinary functions

A
audit-thread-pool: Private ordinary functions

C
copy-node: Private ordinary functions
copy-pool: Private ordinary functions

D
done-p: Public ordinary functions

E
execute-task: Private ordinary functions

F
finish-tasks: Public ordinary functions
Function, (setf node-next): Private ordinary functions
Function, (setf node-prev): Private ordinary functions
Function, (setf node-val): Private ordinary functions
Function, (setf pool-env): Private ordinary functions
Function, (setf pool-lock): Private ordinary functions
Function, (setf pool-queue): Private ordinary functions
Function, (setf pool-size): Private ordinary functions
Function, (setf pool-threads): Private ordinary functions
Function, (setf thread-pool-size): Public ordinary functions
Function, audit-thread-pool: Private ordinary functions
Function, copy-node: Private ordinary functions
Function, copy-pool: Private ordinary functions
Function, done-p: Public ordinary functions
Function, execute-task: Private ordinary functions
Function, finish-tasks: Public ordinary functions
Function, join: Public ordinary functions
Function, make-node: Private ordinary functions
Function, make-pool: Private ordinary functions
Function, make-queue: Public ordinary functions
Function, node-next: Private ordinary functions
Function, node-p: Private ordinary functions
Function, node-prev: Private ordinary functions
Function, node-val: Private ordinary functions
Function, pcall: Public ordinary functions
Function, pool-env: Private ordinary functions
Function, pool-lock: Private ordinary functions
Function, pool-p: Private ordinary functions
Function, pool-queue: Private ordinary functions
Function, pool-size: Private ordinary functions
Function, pool-threads: Private ordinary functions
Function, queue-do-pop: Private ordinary functions
Function, queue-empty-p: Public ordinary functions
Function, queue-length: Public ordinary functions
Function, queue-pop: Public ordinary functions
Function, queue-push: Public ordinary functions
Function, queue-wait: Public ordinary functions
Function, select-one: Public ordinary functions
Function, set-worker-environment: Public ordinary functions
Function, spawn-thread: Private ordinary functions
Function, stop-thread: Private ordinary functions
Function, thread-pool-size: Public ordinary functions
Function, with-locks: Private ordinary functions
Function, worker-thread: Private ordinary functions

G
Generic Function, (setf queue-back): Private generic functions
Generic Function, (setf queue-front): Private generic functions
Generic Function, (setf task-error): Private generic functions
Generic Function, (setf task-status): Private generic functions
Generic Function, (setf task-values): Private generic functions
Generic Function, (setf task-wait-locks): Private generic functions
Generic Function, (setf task-waiting): Private generic functions
Generic Function, queue-back: Private generic functions
Generic Function, queue-condition: Private generic functions
Generic Function, queue-front: Private generic functions
Generic Function, queue-lock: Private generic functions
Generic Function, stop-at-once-p: Private generic functions
Generic Function, task-error: Private generic functions
Generic Function, task-lock: Private generic functions
Generic Function, task-status: Private generic functions
Generic Function, task-thunk: Private generic functions
Generic Function, task-values: Private generic functions
Generic Function, task-wait-locks: Private generic functions
Generic Function, task-waiting: Private generic functions

J
join: Public ordinary functions

M
Macro, pexec: Public macros
Macro, plet: Public macros
Macro, with-local-thread-pool: Public macros
make-node: Private ordinary functions
make-pool: Private ordinary functions
make-queue: Public ordinary functions
Method, (setf queue-back): Private generic functions
Method, (setf queue-front): Private generic functions
Method, (setf task-error): Private generic functions
Method, (setf task-status): Private generic functions
Method, (setf task-values): Private generic functions
Method, (setf task-wait-locks): Private generic functions
Method, (setf task-waiting): Private generic functions
Method, queue-back: Private generic functions
Method, queue-condition: Private generic functions
Method, queue-front: Private generic functions
Method, queue-lock: Private generic functions
Method, stop-at-once-p: Private generic functions
Method, task-error: Private generic functions
Method, task-lock: Private generic functions
Method, task-status: Private generic functions
Method, task-thunk: Private generic functions
Method, task-values: Private generic functions
Method, task-wait-locks: Private generic functions
Method, task-waiting: Private generic functions

N
node-next: Private ordinary functions
node-p: Private ordinary functions
node-prev: Private ordinary functions
node-val: Private ordinary functions

P
pcall: Public ordinary functions
pexec: Public macros
plet: Public macros
pool-env: Private ordinary functions
pool-lock: Private ordinary functions
pool-p: Private ordinary functions
pool-queue: Private ordinary functions
pool-size: Private ordinary functions
pool-threads: Private ordinary functions

Q
queue-back: Private generic functions
queue-back: Private generic functions
queue-condition: Private generic functions
queue-condition: Private generic functions
queue-do-pop: Private ordinary functions
queue-empty-p: Public ordinary functions
queue-front: Private generic functions
queue-front: Private generic functions
queue-length: Public ordinary functions
queue-lock: Private generic functions
queue-lock: Private generic functions
queue-pop: Public ordinary functions
queue-push: Public ordinary functions
queue-wait: Public ordinary functions

S
select-one: Public ordinary functions
set-worker-environment: Public ordinary functions
spawn-thread: Private ordinary functions
stop-at-once-p: Private generic functions
stop-at-once-p: Private generic functions
stop-thread: Private ordinary functions

T
task-error: Private generic functions
task-error: Private generic functions
task-lock: Private generic functions
task-lock: Private generic functions
task-status: Private generic functions
task-status: Private generic functions
task-thunk: Private generic functions
task-thunk: Private generic functions
task-values: Private generic functions
task-values: Private generic functions
task-wait-locks: Private generic functions
task-wait-locks: Private generic functions
task-waiting: Private generic functions
task-waiting: Private generic functions
thread-pool-size: Public ordinary functions

W
with-local-thread-pool: Public macros
with-locks: Private ordinary functions
worker-thread: Private ordinary functions


A.3 Variables