Release 0.9.3
[bordeaux-threads.git] / apiv2 / impl-mkcl.lisp
blobd2739c81e58b5fde75b6b5c50058c192842b5375
1 ;;;; -*- indent-tabs-mode: nil -*-
3 (in-package :bordeaux-threads-2)
5 ;;;
6 ;;; Threads
7 ;;;
9 (deftype native-thread ()
10 'mt:thread)
12 (defun %make-thread (function name)
13 (mt:thread-run-function name function))
15 (defun %current-thread ()
16 mt::*thread*)
18 (defun %thread-name (thread)
19 (mt:thread-name thread))
21 (defun %join-thread (thread)
22 (mt:thread-join thread))
24 (defun %thread-yield ()
25 (mt:thread-yield))
27 ;;;
28 ;;; Introspection/debugging
29 ;;;
31 (defun %all-threads ()
32 (mt:all-threads))
34 (defun %interrupt-thread (thread function)
35 (mt:interrupt-thread thread function))
37 (defun %destroy-thread (thread)
38 (mt:thread-kill thread))
40 (defun %thread-alive-p (thread)
41 (mt:thread-active-p thread))
44 ;;;
45 ;;; Non-recursive locks
46 ;;;
48 (deftype native-lock () 'mp:lock)
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)
55 (when 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)
64 (if timeout
65 `(signal-not-implemented 'with-lock-held :timeout)
66 `(mp:with-lock (,place) ,@body)))
68 ;;;
69 ;;; Recursive locks
70 ;;;
72 (deftype native-recursive-lock ()
73 '(and mp:lock (satisfies mp:recursive-lock-p)))
75 (defun %make-recursive-lock (name)
76 (mp:make-lock :name name :recursive t))
78 (mark-not-implemented 'acquire-recursive-lock :timeout)
79 (defun %acquire-recursive-lock (lock waitp timeout)
80 (when 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)
89 (if timeout
90 `(signal-not-implemented 'with-recursive-lock-held :timeout)
91 `(mp:with-lock (,place) ,@body)))
94 ;;;
95 ;;; Condition variables
96 ;;;
98 (deftype condition-variable ()
99 'mt:condition-variable)
101 (defun %make-condition-variable (name)
102 (declare (ignore name))
103 (mt:make-condition-variable))
105 (mark-not-implemented 'condition-wait :timeout)
106 (defun %condition-wait (cv lock timeout)
107 (when timeout
108 (signal-not-implemented 'condition-wait :timeout))
109 (mt:condition-wait cv lock)
112 (defun %condition-notify (cv)
113 (mt:condition-signal cv))
115 (defun %condition-broadcast (cv)
116 (mt:condition-broadcast cv))