Skip to content
Multithreading and concurrency utilities
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
t
.gitignore
LICENSE
README.md
cl-muth.asd

README.md

cl-muth

Various multithreading and concurrency utilities.

thread-pool

Simple and conventional thread pool.

guarded-reference

A value holder with access to it guarded by a lock.

latch

A synchronization primitive with implicit counter for blocking further execution of threads waiting the latch to be open - when its counter reaches zero.

blocking-queue

A synchronization primitive for thread blocking reads and writes from/into a queue.

scheduler

Simple mechanism for scheduling tasks for execution at specified time or intervals.

Example:

(ql:quickload '(:cl-muth :log4cl))

(defparameter *scheduler* (muth:make-scheduler))
(defparameter *unscheduled-p* nil)

(muth:start-scheduler *scheduler*)

;; Run %report function every second starting after 0.5 seconds until
;; *unscheduled-p* is set to 't
(labels ((%time ()
           (float (/ (get-internal-real-time) internal-time-units-per-second) 0d0))
         (%report ()
           (if *unscheduled-p*
               (muth:unschedule)
               (log:info "Hello there: ~A" (%time)))))
  (muth:schedule *scheduler* #'%report 0.5 1))

;; Evaluate to stop %report from being called every second
; (setf *unscheduled-p* t)

atomic-counter

Efficient only on SBCL and CCL implementations. Fallbacks to blocking operations on others.

Thread safe counter with atomic increment and decrement operations.

spin-lock

Efficient only on SBCL and CCL implementations. Fallbacks to blocking operations on others.

Simple non-blocking spin lock implementation.

Tests

(ql:quickload :cl-muth/tests) (5am:run! :cl-muth.tests)
You can’t perform that action at this time.