Don't define MAKE-MUTEX in two different ways.
[sbcl.git] / src / code / early-thread.lisp
blobcaab469069ccea3916c0a89c12f5df8898000189
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
10 (in-package "SB!THREAD")
12 (eval-when (:compile-toplevel :load-toplevel :execute)
13 (defvar *current-thread* nil))
15 (def!type thread-name () 'simple-string)
17 ;;; THREAD and MUTEX are mutually referential types, and the compiler isn't
18 ;;; generally intelligent enough to compile out-of-line setters efficiently
19 ;;; when it has to type-check an unknown, such as MUTEX-%OWNER which is
20 ;;; (OR NULL THREAD). But this is not a problem for the constructor,
21 ;;; because %OWNER's default is NIL which statically passes the test.
22 ;;; #'(SETF %OWNER) is suboptimally compiled, which is irrelevant,
23 ;;; because it is never called. But you can't use CAS on the slot unless it
24 ;;; is read/write, which necessarily defines a writer (that we don't want).
26 (declaim (inline make-mutex)) ;; for possible DX-allocating
27 (defstruct (mutex
28 (:constructor make-mutex (&key name)))
29 #!+sb-doc
30 "Mutex type."
31 (name nil :type (or null thread-name))
32 (%owner nil :type (or null thread))
33 #!+(and sb-thread sb-futex)
34 (state 0 :type fixnum))
35 (declaim (notinline make-mutex))
37 (defstruct (thread (:constructor %make-thread))
38 #!+sb-doc
39 "Thread type. Do not rely on threads being structs as it may change
40 in future versions."
41 (name nil :type (or thread-name null))
42 (%alive-p nil :type boolean)
43 (%ephemeral-p nil :type boolean)
44 #-sb-xc-host
45 (os-thread 0 :type sb!vm:word)
46 (interruptions nil :type list)
47 ;; On succesful execution of the thread's lambda a list of values.
48 (result 0)
49 (interruptions-lock
50 (make-mutex :name "thread interruptions lock")
51 :type mutex)
52 (result-lock
53 (make-mutex :name "thread result lock")
54 :type mutex)
55 waiting-for)