1 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
4 Copyright
2006, 2007 Greg Pfeil
6 Distributed under the MIT license
(see LICENSE file
)
9 (in-package #:bordeaux-threads
)
13 (defun %make-thread
(function name
)
14 (ccl:process-run-function name function
))
16 (defun current-thread ()
19 (defun threadp (object)
20 (ccl:processp object
))
22 (defun thread-name (thread)
23 (ccl:process-name thread
))
25 ;;; Resource contention: locks and recursive locks
27 (defun make-lock (&optional name
)
30 (defmacro with-lock-held
((place) &body body
)
31 `(ccl:with-lock-grabbed
(,place
) ,@body
))
33 (defun thread-yield ()
34 (ccl:process-allow-schedule
))
36 ;;; Introspection/debugging
41 (defun interrupt-thread (thread function
)
42 (ccl:process-interrupt thread function
))
44 (defun destroy-thread (thread)
45 (signal-error-if-current-thread thread
)
46 (ccl:process-kill thread
))