1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-03 18:50: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) (define (transfer! in out)
(match in (match in
(() (values)) (() (values))
((x) x)
((x . in*) ((x . in*)
(let* ((out* (cons x out)) (let* ((out* (cons x out))
(out** (atomic-box-compare-and-swap! outbox out out*))) (out** (atomic-box-compare-and-swap! outbox out out*)))
@ -83,8 +84,7 @@
(match (atomic-box-swap! inbox '()) (match (atomic-box-swap! inbox '())
(() #f) (() #f)
(in (in
(transfer! in '()) (transfer! in '())))))))
(pop!)))))))
(values push! pop!)) (values push! pop!))
(define (make-guardian) (define (make-guardian)