1 ;;;; -*- indent-tabs-mode: nil -*-
3 (in-package :bordeaux-threads-2
)
9 (deftype native-thread
()
12 (defun %make-thread
(function name
)
13 (mp:process-run-function name function
))
15 (defun current-thread ()
18 (defun %thread-name
(thread)
19 (mp:process-name thread
))
21 (defun %join-thread
(thread)
22 (mp:process-join thread
))
24 (defun %thread-yield
()
28 ;;; Introspection/debugging
31 (defun %all-threads
()
34 (defun %interrupt-thread
(thread function
)
35 (mp:interrupt-process thread function
))
37 (defun %destroy-thread
(thread)
38 (mp:process-kill thread
))
40 (defun %thread-alive-p
(thread)
41 (mp:process-active-p thread
))
45 ;;; Non-recursive locks
48 (deftype native-lock
() 'mp
:mutex
)
50 (defun %make-lock
(name)
51 (mp:make-lock
:name name
))
53 (mark-not-implemented 'acquire-lock
:timeout
)
54 (defun %acquire-lock
(lock waitp timeout
)
56 (signal-not-implemented 'acquire-lock
:timeout
))
57 (mp:get-lock lock waitp
))
59 (defun %release-lock
(lock)
60 (mp:giveup-lock lock
))
62 (mark-not-implemented 'with-lock-held
:timeout
)
63 (defmacro %with-lock
((place timeout
) &body body
)
65 `(signal-not-implemented 'with-lock-held
:timeout
)
66 `(mp:with-lock
(,place
) ,@body
)))
72 (deftype native-recursive-lock
()
73 '(and mp
:mutex
(satisfies mp
:recursive-lock-p
)))
75 (defun %make-recursive-lock
(name)
76 (mp:make-recursive-mutex name
))
78 (mark-not-implemented 'acquire-recursive-lock
:timeout
)
79 (defun %acquire-recursive-lock
(lock waitp timeout
)
81 (signal-not-implemented 'acquire-recursive-lock
:timeout
))
82 (mp:get-lock lock waitp
))
84 (defun %release-recursive-lock
(lock)
85 (mp:giveup-lock lock
))
87 (mark-not-implemented 'with-recursive-lock-held
:timeout
)
88 (defmacro %with-recursive-lock
((place timeout
) &body body
)
90 `(signal-not-implemented 'with-recursive-lock-held
:timeout
)
91 `(mp:with-lock
(,place
) ,@body
)))
95 ;;; Condition variables
98 (deftype condition-variable
()
99 'mp
:condition-variable
)
101 (defun %make-condition-variable
(name)
102 (declare (ignore name
))
103 (mp:make-condition-variable
))
105 (defun %condition-wait
(cv lock timeout
)
107 (mp:condition-variable-timedwait cv lock timeout
)
108 (mp:condition-variable-wait cv lock
)))
110 (defun %condition-notify
(cv)
111 (mp:condition-variable-signal cv
))
113 (defun %condition-broadcast
(cv)
114 (mp:condition-variable-broadcast cv
))