From de0de090b41f3c117a487880e8f3dc2c3a1f657a Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 13 Jun 2019 13:04:44 -0400 Subject: [PATCH] Change 'ref' to 'deref' --- libs/cyclone/concurrency.sld | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/cyclone/concurrency.sld b/libs/cyclone/concurrency.sld index ffb8c72d..2d23d5bd 100644 --- a/libs/cyclone/concurrency.sld +++ b/libs/cyclone/concurrency.sld @@ -20,7 +20,7 @@ make-atom atom atom? - ref + deref swap! compare-and-set! ;; Shared objects @@ -66,8 +66,8 @@ (%make-atom (make-shared (car obj))) (%make-atom #f))) -;; - ref atomic -(define-c ref +;; - deref atomic +(define-c deref "(void *data, int argc, closure _, object k, object obj)" " atomic a; Cyc_check_atomic(data, obj); @@ -88,7 +88,7 @@ ;; That means the function can get called multiple times. That means it needs to be a pure function. Another thing is that you can't control the order of the function calls. If multiple threads are swapping to an Atom at the same time, order is out of the window. So make sure your functions are independent of order, like we talked about before. ;; (define (swap! atom f . args) - (let* ((oldval (ref atom)) + (let* ((oldval (deref atom)) (newval (make-shared (apply f oldval args)))) (if (compare-and-set! atom oldval newval) newval ;; value did not change, return new one