X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fthread.lisp;h=85eb1c82dadf4a8df6f7551a9756a7ca6b2ddab0;hb=6caf3ed5713773cb423f46bf40a29f2438c97c78;hp=029633c5a22e3eec6d6fcebbe01e0d9e0eafcab1;hpb=a05af4f16fc6a79f3725b9c7b46d5967b3dfcaf7;p=sbcl.git diff --git a/src/code/thread.lisp b/src/code/thread.lisp index 029633c..85eb1c8 100644 --- a/src/code/thread.lisp +++ b/src/code/thread.lisp @@ -11,25 +11,33 @@ (in-package "SB!THREAD") +(def!type thread-name () + 'simple-string) + (def!struct (thread (:constructor %make-thread)) #!+sb-doc "Thread type. Do not rely on threads being structs as it may change in future versions." - name - %alive-p - os-thread - interruptions - (interruptions-lock (make-mutex :name "thread interruptions lock")) - result - (result-lock (make-mutex :name "thread result lock"))) + (name nil :type (or thread-name null)) + (%alive-p nil :type boolean) + (os-thread nil :type (or integer null)) + (interruptions nil :type list) + (result nil :type list) + (interruptions-lock + (make-mutex :name "thread interruptions lock") + :type mutex) + (result-lock + (make-mutex :name "thread result lock") + :type mutex) + waiting-for) (def!struct mutex #!+sb-doc "Mutex type." - (name nil :type (or null simple-string)) + (name nil :type (or null thread-name)) (%owner nil :type (or null thread)) #!+(and (not sb-lutex) sb-thread) - (state 0 :type fixnum) + (state 0 :type fixnum) #!+(and sb-lutex sb-thread) (lutex (make-lutex))) @@ -60,15 +68,15 @@ stale value, use MUTEX-OWNER instead." (def!struct spinlock #!+sb-doc "Spinlock type." - (name nil :type (or null simple-string)) + (name nil :type (or null thread-name)) (value nil)) (sb!xc:defmacro with-mutex ((mutex &key (value '*current-thread*) (wait-p t)) &body body) #!+sb-doc - "Acquire MUTEX for the dynamic scope of BODY, setting it to -NEW-VALUE or some suitable default value if NIL. If WAIT-P is non-NIL -and the mutex is in use, sleep until it is available" + "Acquire MUTEX for the dynamic scope of BODY, setting it to VALUE or +some suitable default value if NIL. If WAIT-P is non-NIL and the mutex +is in use, sleep until it is available" `(dx-flet ((with-mutex-thunk () ,@body)) (call-with-mutex #'with-mutex-thunk