Hi!

Does anyone know if Guile plans to have better support for atomic
operations?  For example `atomic-box-fetch-and-add!`.

I know that in theory, one can do the following:
------------------------------------------------------------------------------
(define (atomic-box-fetch-and-apply! box op value)
  (let ([old (atomic-box-ref box)])
    (if (eq? old
             (atomic-box-compare-and-swap! box old (op old value)))
        old
        (atomic-box-fetch-and-apply! box op value))))

(define (atomic-box-fetch-and-add! box value)
  (atomic-box-fetch-and-apply! box + value))

(define (atomic-box-fetch-and-sub! box value)
  (atomic-box-fetch-and-apply! box - value))

(define (atomic-box-fetch-and-xor! box value)
  (atomic-box-fetch-and-apply! box logxor value))

...
------------------------------------------------------------------------------
and it works.

But I think such operations would be faster if available as primitives in
the VM, if that's possible?

-- 
Olivier Dion
Polymtl


Reply via email to