1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-02 02:10:19 +02:00

guardians: speed up atomic fifo

* module/ice-9/guardians.scm (make-atomic-fifo): Instead of transferring
the last element to the outbox, just return it.
This commit is contained in:
Andy Wingo 2025-05-04 20:54:15 +02:00
parent 8b46c321e5
commit 4c76332570

View file

@ -65,6 +65,7 @@
(define (transfer! in out)
(match in
(() (values))
((x) x)
((x . in*)
(let* ((out* (cons x out))
(out** (atomic-box-compare-and-swap! outbox out out*)))
@ -83,8 +84,7 @@
(match (atomic-box-swap! inbox '())
(() #f)
(in
(transfer! in '())
(pop!)))))))
(transfer! in '())))))))
(values push! pop!))
(define (make-guardian)