X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompare-and-swap.impure.lisp;h=b368f8c48292cd67707d7fc06a662182e1362a00;hb=1e786e1a23a1f2276ec2dbe197dcc31a53b43738;hp=6ec6547b07cc00352edd962928c15778676e099d;hpb=76db27f585eda84ab93411dd61b32677355f8cc4;p=sbcl.git diff --git a/tests/compare-and-swap.impure.lisp b/tests/compare-and-swap.impure.lisp index 6ec6547..b368f8c 100644 --- a/tests/compare-and-swap.impure.lisp +++ b/tests/compare-and-swap.impure.lisp @@ -120,6 +120,10 @@ (defstruct box (word 0 :type sb-vm:word)) +;; Have the following tests check that CAS access to the superclass +;; works in the presence of a subclass sharing the conc-name. +(defstruct (subbox (:include box) (:conc-name "BOX-"))) + (defun inc-box (box n) (declare (fixnum n) (box box)) (loop repeat n @@ -412,6 +416,7 @@ (assert (eq :bar (eval `(let (,@(mapcar 'list vars vals)) ,read-form))))))) + (let ((foo (cons :foo nil))) (defun cas-foo (old new) (cas (cdr foo) old new))) @@ -425,3 +430,22 @@ (assert (not (cas bar nil :ok))) (assert (eq :ok (cas bar :ok nil))) (assert (not (cas bar nil t))))) + +(with-test (:name atomic-push + :skipped-on '(not :sb-thread)) + (let ((store (cons nil nil)) + (n 100000)) + (symbol-macrolet ((x (car store)) + (y (cdr store))) + (dotimes (i n) + (push i y)) + (mapc #'sb-thread:join-thread + (loop repeat (ecase sb-vm:n-word-bits (32 100) (64 1000)) + collect (sb-thread:make-thread + (lambda () + (loop for z = (atomic-pop y) + while z + do (atomic-push z x) + (sleep 0.00001)))))) + (assert (not y)) + (assert (eql n (length x))))))