Skip to content

Commit 5a8dbf8

Browse files
wat
PiperOrigin-RevId: 615801017
1 parent ef59ed2 commit 5a8dbf8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

thread-test.lisp

+5-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
(expect (eq (current-thread) (current-thread)))
5454
(expect (eq (current-thread) (current-thread))))))
5555

56+
#+nil
5657
(deftest test-recursive-mutex ()
5758
(let ((mutex (make-mutex "TEST"))
5859
(count 0))
@@ -68,7 +69,7 @@
6869
(increment))))
6970
(expect (= count 500))))
7071

71-
(deftest test-frmutex ()
72+
#+nil(deftest test-frmutex ()
7273
(let ((mutex (make-frmutex "FR"))
7374
(count1 0)
7475
(count2 0))
@@ -98,6 +99,7 @@
9899
(let ((mutex (make-frmutex)))
99100
(expect mutex)))
100101

102+
#+nil
101103
(deftest test-unprotected-mutex-safe ()
102104
(declare (optimize (safety 3)))
103105
(let ((mutex (make-mutex "TEST")))
@@ -106,6 +108,7 @@
106108
(with-mutex (mutex :protect nil)
107109
(throw :foo :no-error))))))
108110

111+
#+nil
109112
(deftest test-unprotected-mutex-unsafe ()
110113
(declare (optimize (safety 0)))
111114
(let ((mutex (make-mutex "TEST")))
@@ -119,6 +122,7 @@
119122
(expect (holding-mutex-p mutex))))
120123

121124

125+
#+nil
122126
(deftest test-with-value-computed-once ()
123127
(let ((promise (make-promise "once"))
124128
(count0 (list 0))

thread.lisp

+8
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ Related:
188188
#-(or ccl sbcl)
189189
(assert nil nil "Unimplemented: HOLDING-MUTEX-P"))
190190

191+
(defmacro with-mutex ((m) &body body) `(sb-thread:with-mutex (,m) ,@body))
192+
193+
#+nil
191194
(defmacro with-mutex ((mutex &key (lock t) (reenter t) (protect t) (inline :default))
192195
&environment env &body body)
193196
"Defines BODY as a critical section that is guarded by MUTEX.
@@ -225,6 +228,7 @@ there is still possibility that the MUTEX remains locked resulting in an undefin
225228
(,lock-form (,mutex) (&body))
226229
(&body))))))))
227230

231+
#+nil
228232
(defmacro with-mutex-once ((mutex) &environment env &body body)
229233
"Executes BODY while holding the MUTEX.
230234
Checks that the current thread is NOT the owner of the MUTEX."
@@ -236,6 +240,7 @@ Checks that the current thread is NOT the owner of the MUTEX."
236240
(with-recursive-lock-held (,mutex)
237241
(locally ,@body)))))
238242

243+
#+nil
239244
(defmacro with-unprotected-mutex ((mutex &key (lock t) (reenter t))
240245
&environment env &body body)
241246
"Like WITH-MUTEX but without an (expensive) UNWIND-PROTECT.
@@ -270,6 +275,7 @@ If REENTER is NIL and the MUTEX is owned by the current thread, a MUTEX-ERROR is
270275
(error 'mutex-error "Unwind with an unprotected mutex ~A!" ,mutex)))))
271276
(form)))))
272277

278+
#+nil
273279
(defmacro with-unprotected-mutex-once ((mutex &key (lock t)) &body body)
274280
"Like WITH-MUTEX-ONCE but without an (expensive) UNWIND-PROTECT.
275281
The mutex is locked if the LOCK form evaluates to non-nil at runtime.
@@ -313,6 +319,7 @@ The promise must not be fulfilled, yet."
313319
(dcheck (promise-fulfilled-p promise))
314320
(cdr promise))
315321

322+
#+nil
316323
(defun %with-value-computed-once (promise body)
317324
(declare (promise promise) (function body))
318325
;; Check if promise is not fulfilled, yet?
@@ -328,6 +335,7 @@ The promise must not be fulfilled, yet."
328335
;; Return results.
329336
(promise-value promise))
330337

338+
#+nil
331339
(defmacro with-value-computed-once ((promise) &body body)
332340
"Compute the value of the BODY only once and store it in the PROMISE.
333341

0 commit comments

Comments
 (0)