Various multithreading and concurrency utilities.
Simple and conventional thread pool.
A value holder with access to it guarded by a lock.
A synchronization primitive with implicit counter for blocking further execution of threads waiting the latch to be open - when its counter reaches zero.
A synchronization primitive for thread blocking reads and writes from/into a queue.
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)
Efficient only on SBCL and CCL implementations. Fallbacks to blocking
operations on others.
Thread safe counter with atomic increment and decrement operations.
Efficient only on SBCL and CCL implementations. Fallbacks to blocking
operations on others.
Simple non-blocking spin lock implementation.
(ql:quickload :cl-muth/tests) (5am:run! :cl-muth.tests)