2 Copyright
2006, 2007 Greg Pfeil
4 Distributed under the MIT license
(see LICENSE file
)
7 (in-package #:bordeaux-threads
)
9 ;;; the implementation of the Armed Bear thread interface can be found in
10 ;;; src/org/armedbearlisp/LispThread.java
14 (defun make-thread (function &key name
)
15 (ext:make-thread function
:name name
))
17 (defun current-thread ()
20 (defun thread-name (thread)
21 (ext:thread-name thread
))
23 ;;; Yes, this is nasty
24 (defun threadp (object)
25 (handler-case (progn (thread-name object
) t
)
28 ;;; Resource contention: locks and recursive locks
30 ;;; Don't know what the arguments to MAKE-THREAD-LOCK are, but it
31 ;;; doesn't mind being a thunk
32 (defun make-lock (&optional name
)
33 (declare (ignore name
))
34 (ext:make-thread-lock
))
36 (defun acquire-lock (lock &optional
(wait-p t
))
37 (declare (ignore wait-p
))
38 (ext:thread-lock lock
))
40 (defun release-lock (lock)
41 (ext:thread-unlock lock
))
43 (defmacro with-lock-held
((place) &body body
)
44 `(ext:with-thread-lock
(,place
) ,@body
))
46 ;;; Resource contention: condition variables
48 (defun thread-yield ()
51 ;;; Introspection/debugging
53 (defun interrupt-thread (thread function
)
54 (ext:interrupt-thread thread function
))
56 (defun destroy-thread (thread)
57 (signal-error-if-current-thread thread
)
58 (ext:destroy-thread thread
))
60 (defun thread-alive-p (thread)
61 (ext:thread-alive-p thread
))