Add semaphores abstraction to bordeaux-threads
[bordeaux-threads.git] / src / pkgdcl.lisp
blob1c1e45d634296518b539d34daf117796e200427d
1 ;;;; -*- indent-tabs-mode: nil -*-
3 (cl:defpackage :bordeaux-threads
4 (:nicknames #:bt)
5 (:use #:cl #:alexandria)
6 #+abcl
7 (:import-from :java #:jnew #:jcall #:jmethod)
8 (:export #:thread #:make-thread #:current-thread #:threadp #:thread-name
9 #:start-multiprocessing
10 #:*default-special-bindings* #:*standard-io-bindings*
11 #:*supports-threads-p*
13 #:lock #:make-lock #:lock-p
14 #:acquire-lock #:release-lock #:with-lock-held
16 #:recursive-lock #:make-recursive-lock #:recursive-lock-p
17 #:acquire-recursive-lock #:release-recursive-lock #:with-recursive-lock-held
19 #:make-condition-variable #:condition-wait #:condition-notify
21 #:make-semaphore #:signal-semaphore #:wait-on-semaphore #:semaphore #:semaphore-p
23 #:with-timeout #:timeout
25 #:all-threads #:interrupt-thread #:destroy-thread #:thread-alive-p
26 #:join-thread #:thread-yield)
27 (:documentation "BORDEAUX-THREADS is a proposed standard for a minimal
28 MP/threading interface. It is similar to the CLIM-SYS threading and
29 lock support, but for the following broad differences:
31 1) Some behaviours are defined in additional detail: attention has
32 been given to special variable interaction, whether and when
33 cleanup forms are run. Some behaviours are defined in less
34 detail: an implementation that does not support multiple
35 threads is not required to use a new list (nil) for a lock, for
36 example.
38 2) Many functions which would be difficult, dangerous or inefficient
39 to provide on some implementations have been removed. Chiefly
40 these are functions such as thread-wait which expect for
41 efficiency that the thread scheduler is written in Lisp and
42 'hookable', which can't sensibly be done if the scheduler is
43 external to the Lisp image, or the system has more than one CPU.
45 3) Unbalanced ACQUIRE-LOCK and RELEASE-LOCK functions have been
46 added.
48 4) Posix-style condition variables have been added, as it's not
49 otherwise possible to implement them correctly using the other
50 operations that are specified.
52 Threads may be implemented using whatever applicable techniques are
53 provided by the operating system: user-space scheduling,
54 kernel-based LWPs or anything else that does the job.
56 Some parts of this specification can also be implemented in a Lisp
57 that does not support multiple threads. Thread creation and some
58 thread inspection operations will not work, but the locking
59 functions are still present (though they may do nothing) so that
60 thread-safe code can be compiled on both multithread and
61 single-thread implementations without need of conditionals.
63 To avoid conflict with existing MP/threading interfaces in
64 implementations, these symbols live in the BORDEAUX-THREADS package.
65 Implementations and/or users may also make them visible or exported
66 in other more traditionally named packages."))