Add GUARANTEE-THREAD-MUTEX-OWNED.
authorTaylor R Campbell <campbell@mumble.net>
Thu, 13 Nov 2014 22:45:03 +0000 (22:45 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Thu, 13 Nov 2014 22:45:03 +0000 (22:45 +0000)
src/runtime/runtime.pkg
src/runtime/thread.scm

index 47b1729bc185d704383be67b6a7c3998498d6da1..cb91b13e00bcc13d262ff918419437ff88e48536 100644 (file)
@@ -4992,6 +4992,7 @@ USA.
          deregister-timer-event
          detach-thread
          exit-current-thread
+         guarantee-thread-mutex-owned
          join-thread
          lock-thread-mutex
          make-thread-mutex
index 9ba3ff8859a582baed62915e4c53ee626c970319..e88751ad1d282f4af35e95ae495368c75f51c89c 100644 (file)
@@ -1039,6 +1039,13 @@ USA.
   (if (not (thread-mutex? mutex))
       (error:wrong-type-argument mutex "thread-mutex" procedure)))
 
+(define (guarantee-thread-mutex-owned mutex #!optional caller)
+  (guarantee-thread-mutex mutex 'GUARANTEE-THREAD-MUTEX-OWNED)
+  (if (not (eq? (current-thread) (thread-mutex/owner mutex)))
+      (if (default-object? caller)
+         (error "Don't own mutex:" mutex)
+         (error "Don't own mutex:" mutex caller))))
+
 (define (thread-mutex-owner mutex)
   (guarantee-thread-mutex mutex 'THREAD-MUTEX-OWNER)
   (thread-mutex/owner mutex))