X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fcompare-and-swap.impure.lisp;h=e1dc09bfa94064376aae6302334e17addfeb94b6;hb=179de85ab4fdff049c72ddb2767b93d838494b09;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..e1dc09b 100644 --- a/tests/compare-and-swap.impure.lisp +++ b/tests/compare-and-swap.impure.lisp @@ -412,6 +412,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 +426,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))))))