The cl-freelock Reference Manual

This is the cl-freelock Reference Manual, version 0.1.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Fri May 15 11:48:31 2026 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 cl-freelock

lock-free concurrency primitives, written in pure Common Lisp.

Author

<>

License

MIT

Version

0.1.1

Source

cl-freelock.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 cl-freelock/cl-freelock.asd

Source

cl-freelock.asd.

Parent Component

cl-freelock (system).

ASDF Systems

cl-freelock.


3.1.2 cl-freelock/package.lisp

Source

cl-freelock.asd.

Parent Component

cl-freelock (system).

Packages

cl-freelock.


3.1.3 cl-freelock/src/atomics.lisp

Dependency

package.lisp (file).

Source

cl-freelock.asd.

Parent Component

cl-freelock (system).

Public Interface
Internals

3.1.4 cl-freelock/src/queue.lisp

Dependency

src/atomics.lisp (file).

Source

cl-freelock.asd.

Parent Component

cl-freelock (system).

Public Interface
Internals

3.1.5 cl-freelock/src/bounded-queue.lisp

Dependency

src/queue.lisp (file).

Source

cl-freelock.asd.

Parent Component

cl-freelock (system).

Public Interface
Internals

3.1.6 cl-freelock/src/spsc-queue.lisp

Dependency

src/bounded-queue.lisp (file).

Source

cl-freelock.asd.

Parent Component

cl-freelock (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 cl-freelock

Source

package.lisp.

Nickname

fl

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 Macros

Macro: atomic-incf (atomic-ref &optional delta)

Atomically increments the value of the atomic-ref by DELTA. Returns the new value. Implemented via a CAS loop for portability.

Package

cl-freelock.

Source

src/atomics.lisp.

Macro: cas (place old new)

A portable Compare-and-Swap macro.
Atomically stores NEW in PLACE if the current value of PLACE is EQ to OLD. Returns the old value of PLACE. The comparison is done by EQ.

Package

cl-freelock.

Source

src/atomics.lisp.


5.1.2 Ordinary functions

Reader: atomic-ref-value (instance)
Writer: (setf atomic-ref-value) (instance)
Package

cl-freelock.

Source

src/atomics.lisp.

Target Slot

value.

Function: bounded-queue-empty-p (queue)

Returns T if the queue appears to be empty, and NIL otherwise.

Package

cl-freelock.

Source

src/bounded-queue.lisp.

Function: bounded-queue-full-p (queue)

Returns T if the queue appears to be full, NIL otherwise.

Package

cl-freelock.

Source

src/bounded-queue.lisp.

Function: bounded-queue-pop (queue)

Pops an object from the queue. Returns (values object t) or (values nil nil). This operation is lock-free and non-blocking.

Package

cl-freelock.

Source

src/bounded-queue.lisp.

Function: bounded-queue-pop-batch (queue count)

Pops up to COUNT objects from the queue. Returns two values: 1. A (possibly empty) list of objects.
2. T if any objects were popped, NIL otherwise.

Package

cl-freelock.

Source

src/bounded-queue.lisp.

Function: bounded-queue-push (queue object)

Pushes an object onto the bounded queue. Returns T on success, NIL if full. This operation is lock-free and non-blocking.

Package

cl-freelock.

Source

src/bounded-queue.lisp.

Function: bounded-queue-push-batch (queue sequence)

Pushes a sequence of objects onto the queue. Returns T on success, NIL if there is not enough space for the entire sequence.

Package

cl-freelock.

Source

src/bounded-queue.lisp.

Function: make-atomic-ref (value)
Package

cl-freelock.

Source

src/atomics.lisp.

Function: make-bounded-queue (capacity)

Creates a new lock-free, bounded queue. Capacity MUST be a power of two.

Package

cl-freelock.

Source

src/bounded-queue.lisp.

Function: make-queue ()

Creates a new lock-free, unbounded queue.

Package

cl-freelock.

Source

src/queue.lisp.

Function: make-spsc-queue (capacity)

Creates a new lock-free, SPSC bounded queue. Capacity ABSOLUTELY MUST be a power of two.

Package

cl-freelock.

Source

src/spsc-queue.lisp.

Function: memory-barrier ()

Full memory barrier. All memory operations before
the barrier are completed before any memory operations after it.

Package

cl-freelock.

Source

src/atomics.lisp.

Function: queue-empty-p (queue)

Returns T if the queue appears to be empty, NIL otherwise.
NOTE: In a concurrent environment, the state can change immediately after this call.

Package

cl-freelock.

Source

src/queue.lisp.

Function: queue-pop (queue)

Pops an object from the queue. Returns two values: the object and T on success, or (NIL, NIL) if the queue is empty. This operation is lock-free.

Package

cl-freelock.

Source

src/queue.lisp.

Function: queue-push (queue object)

Pushes an object onto the queue. This operation is lock-free and non-blocking.

Package

cl-freelock.

Source

src/queue.lisp.

Function: spsc-pop (queue)

Pops an object from the SPSC queue. Must only be called by the consumer thread. Returns (values object t) or (values nil nil) if the queue is empty.

Package

cl-freelock.

Source

src/spsc-queue.lisp.

Function: spsc-push (queue object)

Pushes an object onto the SPSC queue. Must only be called by the producer thread. Returns T on success, and NIL if the queue is full.

Package

cl-freelock.

Source

src/spsc-queue.lisp.


5.1.3 Generic functions

Generic Reader: bounded-queue-capacity (object)
Package

cl-freelock.

Methods
Reader Method: bounded-queue-capacity ((bounded-queue bounded-queue))

automatically generated reader method

Source

src/bounded-queue.lisp.

Target Slot

capacity.


5.1.4 Standalone methods

Method: initialize-instance :after ((queue spsc-queue) &key)
Source

src/spsc-queue.lisp.

Method: initialize-instance :after ((queue bounded-queue) &key)
Source

src/bounded-queue.lisp.

Method: initialize-instance :after ((queue queue) &key)
Source

src/queue.lisp.


5.1.5 Structures

Structure: atomic-ref
Package

cl-freelock.

Source

src/atomics.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: value
Initform

(error "value is required")

Readers

atomic-ref-value.

Writers

(setf atomic-ref-value).


5.1.6 Classes

Class: bounded-queue
Package

cl-freelock.

Source

src/bounded-queue.lisp.

Direct methods
Direct slots
Slot: buffer
Type

(simple-array t (*))

Initargs

:buffer

Readers

bounded-queue-buffer.

Writers

This slot is read-only.

Slot: sequences
Type

(simple-array t (*))

Initargs

:sequences

Readers

bounded-queue-sequences.

Writers

This slot is read-only.

Slot: capacity
Type

(unsigned-byte 32)

Initargs

:capacity

Readers

bounded-queue-capacity.

Writers

This slot is read-only.

Slot: mask
Type

(unsigned-byte 32)

Readers

bounded-queue-mask.

Writers

This slot is read-only.

Slot: head
Initform

(cl-freelock:make-atomic-ref 0)

Readers

bounded-queue-head.

Writers

This slot is read-only.

Slot: tail
Initform

(cl-freelock:make-atomic-ref 0)

Readers

bounded-queue-tail.

Writers

This slot is read-only.

Class: queue
Package

cl-freelock.

Source

src/queue.lisp.

Direct methods
Direct slots
Slot: head
Readers

queue-head.

Writers

This slot is read-only.

Slot: tail
Readers

queue-tail.

Writers

This slot is read-only.

Class: spsc-queue
Package

cl-freelock.

Source

src/spsc-queue.lisp.

Direct methods
Direct slots
Slot: buffer
Type

(simple-array t (*))

Initargs

:buffer

Readers

spsc-queue-buffer.

Writers

This slot is read-only.

Slot: capacity
Type

(unsigned-byte 32)

Initargs

:capacity

Readers

spsc-queue-capacity.

Writers

This slot is read-only.

Slot: mask
Type

(unsigned-byte 32)

Readers

spsc-queue-mask.

Writers

This slot is read-only.

Slot: tail
Type

fixnum

Initform

0

Readers

spsc-queue-tail.

Writers

(setf spsc-queue-tail).

Slot: p-pad1
Slot: p-pad2
Slot: p-pad3
Slot: p-pad4
Slot: p-pad5
Slot: p-pad6
Slot: p-pad7
Slot: head
Type

fixnum

Initform

0

Readers

spsc-queue-head.

Writers

(setf spsc-queue-head).

Slot: c-pad1
Slot: c-pad2
Slot: c-pad3
Slot: c-pad4
Slot: c-pad5
Slot: c-pad6
Slot: c-pad7

5.2 Internals


5.2.1 Special variables

Special Variable: *sbcl-barrier-dummy*
Package

cl-freelock.

Source

src/atomics.lisp.


5.2.2 Ordinary functions

Function: atomic-ref-p (object)
Package

cl-freelock.

Source

src/atomics.lisp.

Function: copy-atomic-ref (instance)
Package

cl-freelock.

Source

src/atomics.lisp.

Function: copy-queue-node (instance)
Package

cl-freelock.

Source

src/queue.lisp.

Function: make-queue-node (value)
Package

cl-freelock.

Source

src/queue.lisp.

Reader: queue-node-next (instance)
Package

cl-freelock.

Source

src/queue.lisp.

Target Slot

next.

Function: queue-node-p (object)
Package

cl-freelock.

Source

src/queue.lisp.

Reader: queue-node-value (instance)
Package

cl-freelock.

Source

src/queue.lisp.

Target Slot

value.

Function: thread-yield ()

A portable function to yield the current thread’s timeslice to the OS.

Package

cl-freelock.

Source

src/atomics.lisp.


5.2.3 Generic functions

Generic Reader: bounded-queue-buffer (object)
Package

cl-freelock.

Methods
Reader Method: bounded-queue-buffer ((bounded-queue bounded-queue))

automatically generated reader method

Source

src/bounded-queue.lisp.

Target Slot

buffer.

Generic Reader: bounded-queue-head (object)
Package

cl-freelock.

Methods
Reader Method: bounded-queue-head ((bounded-queue bounded-queue))

automatically generated reader method

Source

src/bounded-queue.lisp.

Target Slot

head.

Generic Reader: bounded-queue-mask (object)
Package

cl-freelock.

Methods
Reader Method: bounded-queue-mask ((bounded-queue bounded-queue))

automatically generated reader method

Source

src/bounded-queue.lisp.

Target Slot

mask.

Generic Reader: bounded-queue-sequences (object)
Package

cl-freelock.

Methods
Reader Method: bounded-queue-sequences ((bounded-queue bounded-queue))

automatically generated reader method

Source

src/bounded-queue.lisp.

Target Slot

sequences.

Generic Reader: bounded-queue-tail (object)
Package

cl-freelock.

Methods
Reader Method: bounded-queue-tail ((bounded-queue bounded-queue))

automatically generated reader method

Source

src/bounded-queue.lisp.

Target Slot

tail.

Generic Reader: queue-head (object)
Package

cl-freelock.

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

automatically generated reader method

Source

src/queue.lisp.

Target Slot

head.

Generic Reader: queue-tail (object)
Package

cl-freelock.

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

automatically generated reader method

Source

src/queue.lisp.

Target Slot

tail.

Generic Reader: spsc-queue-buffer (object)
Package

cl-freelock.

Methods
Reader Method: spsc-queue-buffer ((spsc-queue spsc-queue))

automatically generated reader method

Source

src/spsc-queue.lisp.

Target Slot

buffer.

Generic Reader: spsc-queue-capacity (object)
Package

cl-freelock.

Methods
Reader Method: spsc-queue-capacity ((spsc-queue spsc-queue))

automatically generated reader method

Source

src/spsc-queue.lisp.

Target Slot

capacity.

Generic Reader: spsc-queue-head (object)
Package

cl-freelock.

Methods
Reader Method: spsc-queue-head ((spsc-queue spsc-queue))

automatically generated reader method

Source

src/spsc-queue.lisp.

Target Slot

head.

Generic Writer: (setf spsc-queue-head) (object)
Package

cl-freelock.

Methods
Writer Method: (setf spsc-queue-head) ((spsc-queue spsc-queue))

automatically generated writer method

Source

src/spsc-queue.lisp.

Target Slot

head.

Generic Reader: spsc-queue-mask (object)
Package

cl-freelock.

Methods
Reader Method: spsc-queue-mask ((spsc-queue spsc-queue))

automatically generated reader method

Source

src/spsc-queue.lisp.

Target Slot

mask.

Generic Reader: spsc-queue-tail (object)
Package

cl-freelock.

Methods
Reader Method: spsc-queue-tail ((spsc-queue spsc-queue))

automatically generated reader method

Source

src/spsc-queue.lisp.

Target Slot

tail.

Generic Writer: (setf spsc-queue-tail) (object)
Package

cl-freelock.

Methods
Writer Method: (setf spsc-queue-tail) ((spsc-queue spsc-queue))

automatically generated writer method

Source

src/spsc-queue.lisp.

Target Slot

tail.


5.2.4 Structures

Structure: queue-node
Package

cl-freelock.

Source

src/queue.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: value
Initform

cl-freelock::value

Readers

queue-node-value.

Writers

This slot is read-only.

Slot: next
Initform

(cl-freelock:make-atomic-ref nil)

Readers

queue-node-next.

Writers

This slot is read-only.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
A   B   C   F   G   I   M   Q   S   T  
Index Entry  Section

(
(setf atomic-ref-value): Public ordinary functions
(setf spsc-queue-head): Private generic functions
(setf spsc-queue-head): Private generic functions
(setf spsc-queue-tail): Private generic functions
(setf spsc-queue-tail): Private generic functions

A
atomic-incf: Public macros
atomic-ref-p: Private ordinary functions
atomic-ref-value: Public ordinary functions

B
bounded-queue-buffer: Private generic functions
bounded-queue-buffer: Private generic functions
bounded-queue-capacity: Public generic functions
bounded-queue-capacity: Public generic functions
bounded-queue-empty-p: Public ordinary functions
bounded-queue-full-p: Public ordinary functions
bounded-queue-head: Private generic functions
bounded-queue-head: Private generic functions
bounded-queue-mask: Private generic functions
bounded-queue-mask: Private generic functions
bounded-queue-pop: Public ordinary functions
bounded-queue-pop-batch: Public ordinary functions
bounded-queue-push: Public ordinary functions
bounded-queue-push-batch: Public ordinary functions
bounded-queue-sequences: Private generic functions
bounded-queue-sequences: Private generic functions
bounded-queue-tail: Private generic functions
bounded-queue-tail: Private generic functions

C
cas: Public macros
copy-atomic-ref: Private ordinary functions
copy-queue-node: Private ordinary functions

F
Function, (setf atomic-ref-value): Public ordinary functions
Function, atomic-ref-p: Private ordinary functions
Function, atomic-ref-value: Public ordinary functions
Function, bounded-queue-empty-p: Public ordinary functions
Function, bounded-queue-full-p: Public ordinary functions
Function, bounded-queue-pop: Public ordinary functions
Function, bounded-queue-pop-batch: Public ordinary functions
Function, bounded-queue-push: Public ordinary functions
Function, bounded-queue-push-batch: Public ordinary functions
Function, copy-atomic-ref: Private ordinary functions
Function, copy-queue-node: Private ordinary functions
Function, make-atomic-ref: Public ordinary functions
Function, make-bounded-queue: Public ordinary functions
Function, make-queue: Public ordinary functions
Function, make-queue-node: Private ordinary functions
Function, make-spsc-queue: Public ordinary functions
Function, memory-barrier: Public ordinary functions
Function, queue-empty-p: Public ordinary functions
Function, queue-node-next: Private ordinary functions
Function, queue-node-p: Private ordinary functions
Function, queue-node-value: Private ordinary functions
Function, queue-pop: Public ordinary functions
Function, queue-push: Public ordinary functions
Function, spsc-pop: Public ordinary functions
Function, spsc-push: Public ordinary functions
Function, thread-yield: Private ordinary functions

G
Generic Function, (setf spsc-queue-head): Private generic functions
Generic Function, (setf spsc-queue-tail): Private generic functions
Generic Function, bounded-queue-buffer: Private generic functions
Generic Function, bounded-queue-capacity: Public generic functions
Generic Function, bounded-queue-head: Private generic functions
Generic Function, bounded-queue-mask: Private generic functions
Generic Function, bounded-queue-sequences: Private generic functions
Generic Function, bounded-queue-tail: Private generic functions
Generic Function, queue-head: Private generic functions
Generic Function, queue-tail: Private generic functions
Generic Function, spsc-queue-buffer: Private generic functions
Generic Function, spsc-queue-capacity: Private generic functions
Generic Function, spsc-queue-head: Private generic functions
Generic Function, spsc-queue-mask: Private generic functions
Generic Function, spsc-queue-tail: Private generic functions

I
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods
initialize-instance: Public standalone methods

M
Macro, atomic-incf: Public macros
Macro, cas: Public macros
make-atomic-ref: Public ordinary functions
make-bounded-queue: Public ordinary functions
make-queue: Public ordinary functions
make-queue-node: Private ordinary functions
make-spsc-queue: Public ordinary functions
memory-barrier: Public ordinary functions
Method, (setf spsc-queue-head): Private generic functions
Method, (setf spsc-queue-tail): Private generic functions
Method, bounded-queue-buffer: Private generic functions
Method, bounded-queue-capacity: Public generic functions
Method, bounded-queue-head: Private generic functions
Method, bounded-queue-mask: Private generic functions
Method, bounded-queue-sequences: Private generic functions
Method, bounded-queue-tail: Private generic functions
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, initialize-instance: Public standalone methods
Method, queue-head: Private generic functions
Method, queue-tail: Private generic functions
Method, spsc-queue-buffer: Private generic functions
Method, spsc-queue-capacity: Private generic functions
Method, spsc-queue-head: Private generic functions
Method, spsc-queue-mask: Private generic functions
Method, spsc-queue-tail: Private generic functions

Q
queue-empty-p: Public ordinary functions
queue-head: Private generic functions
queue-head: Private generic functions
queue-node-next: Private ordinary functions
queue-node-p: Private ordinary functions
queue-node-value: Private ordinary functions
queue-pop: Public ordinary functions
queue-push: Public ordinary functions
queue-tail: Private generic functions
queue-tail: Private generic functions

S
spsc-pop: Public ordinary functions
spsc-push: Public ordinary functions
spsc-queue-buffer: Private generic functions
spsc-queue-buffer: Private generic functions
spsc-queue-capacity: Private generic functions
spsc-queue-capacity: Private generic functions
spsc-queue-head: Private generic functions
spsc-queue-head: Private generic functions
spsc-queue-mask: Private generic functions
spsc-queue-mask: Private generic functions
spsc-queue-tail: Private generic functions
spsc-queue-tail: Private generic functions

T
thread-yield: Private ordinary functions


A.3 Variables

Jump to:   *  
B   C   H   M   N   P   S   T   V  
Index Entry  Section

*
*sbcl-barrier-dummy*: Private special variables

B
buffer: Public classes
buffer: Public classes

C
c-pad1: Public classes
c-pad2: Public classes
c-pad3: Public classes
c-pad4: Public classes
c-pad5: Public classes
c-pad6: Public classes
c-pad7: Public classes
capacity: Public classes
capacity: Public classes

H
head: Public classes
head: Public classes
head: Public classes

M
mask: Public classes
mask: Public classes

N
next: Private structures

P
p-pad1: Public classes
p-pad2: Public classes
p-pad3: Public classes
p-pad4: Public classes
p-pad5: Public classes
p-pad6: Public classes
p-pad7: Public classes

S
sequences: Public classes
Slot, buffer: Public classes
Slot, buffer: Public classes
Slot, c-pad1: Public classes
Slot, c-pad2: Public classes
Slot, c-pad3: Public classes
Slot, c-pad4: Public classes
Slot, c-pad5: Public classes
Slot, c-pad6: Public classes
Slot, c-pad7: Public classes
Slot, capacity: Public classes
Slot, capacity: Public classes
Slot, head: Public classes
Slot, head: Public classes
Slot, head: Public classes
Slot, mask: Public classes
Slot, mask: Public classes
Slot, next: Private structures
Slot, p-pad1: Public classes
Slot, p-pad2: Public classes
Slot, p-pad3: Public classes
Slot, p-pad4: Public classes
Slot, p-pad5: Public classes
Slot, p-pad6: Public classes
Slot, p-pad7: Public classes
Slot, sequences: Public classes
Slot, tail: Public classes
Slot, tail: Public classes
Slot, tail: Public classes
Slot, value: Public structures
Slot, value: Private structures
Special Variable, *sbcl-barrier-dummy*: Private special variables

T
tail: Public classes
tail: Public classes
tail: Public classes

V
value: Public structures
value: Private structures