WITH-SPINLOCK compatibility layer was broken
[sbcl.git] / tests / threads.impure.lisp
index 71eb25e..8bd9f19 100644 (file)
     (let ((res (list (sb-thread:join-thread t1)
                      (sb-thread:join-thread t2))))
       (assert (equal '(:ok :ok) res)))))
+
+(with-test (:name :spinlock-api)
+  (let* ((warned 0)
+         (funs
+           (handler-bind ((sb-int:early-deprecation-warning (lambda (_)
+                                                              (declare (ignore _))
+                                                              (incf warned))))
+             (list (compile nil `(lambda (lock)
+                                   (sb-thread::with-spinlock (lock)
+                                     t)))
+                   (compile nil `(lambda ()
+                                   (sb-thread::make-spinlock :name "foo")))
+                   (compile nil `(lambda (lock)
+                                   (sb-thread::get-spinlock lock)))
+                   (compile nil `(lambda (lock)
+                                   (sb-thread::release-spinlock lock)))))))
+    (assert (eql 4 warned))
+    (handler-bind ((warning #'error))
+      (destructuring-bind (with make get release) funs
+        (let ((lock (funcall make)))
+          (funcall get lock)
+          (funcall release lock)
+          (assert (eq t (funcall with lock))))))))