Implement atomics for CMUCL
[bordeaux-threads.git] / apiv2 / pkgdcl.lisp
blob730f6ffa607afa9775a03bf9adbde5e25d5f75e8
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-lisp; Base: 10; Package: CL-USER -*-
2 ;;;; The above modeline is required for Genera. Do not change.
4 (defpackage :bt2
5 (:nicknames :bordeaux-threads-2)
6 (:use :common-lisp :alexandria :global-vars)
7 #+abcl
8 (:import-from :java #:jnew #:jcall #:jclass #:jmethod)
9 #+sbcl
10 (:import-from :sb-ext #:timeout)
12 (:export
13 #:+supports-threads-p+
14 #:bordeaux-threads-error
15 #:not-implemented)
17 ;; Threads
18 (:export
19 #:thread
20 #:thread-name
21 #:thread-native-thread
22 #:threadp
23 #:make-thread
24 #:*default-special-bindings*
25 #:*standard-io-bindings*
26 #:current-thread
27 #:all-threads
28 #:start-multiprocessing
30 #:interrupt-thread
31 #:signal-in-thread
32 #:warn-in-thread
33 #:error-in-thread
34 #:destroy-thread
35 #:thread-alive-p
36 #:join-thread
37 #:abnormal-exit
38 #:abnormal-exit-condition
39 #:thread-yield)
41 ;; Locks
42 (:export
43 #:lock
44 #:lockp
45 #:recursive-lock
46 #:recursive-lock-p
47 #:lock-name
48 #:lock-native-lock
49 #:native-lock
50 #:native-lock-p
51 #:native-recursive-lock
52 #:native-recursive-lock-p
54 #:make-lock
55 #:acquire-lock
56 #:release-lock
57 #:with-lock-held
59 #:make-recursive-lock
60 #:acquire-recursive-lock
61 #:release-recursive-lock
62 #:with-recursive-lock-held)
64 ;; Condition variables
65 (:export
66 #:condition-variable
67 #:condition-variable-p
68 #:make-condition-variable
69 #:condition-wait
70 #:condition-notify
71 #:condition-broadcast)
73 ;; Semaphores
74 (:export
75 #:semaphore
76 #:semaphorep
77 #:make-semaphore
78 #:signal-semaphore
79 #:wait-on-semaphore)
81 ;; Atomic operations
82 (:export
83 #:atomic-integer
84 #:make-atomic-integer
85 #:atomic-integer-compare-and-swap
86 #:atomic-integer-decf
87 #:atomic-integer-incf
88 #:atomic-integer-value)
90 ;; Timeouts
91 (:export
92 #:timeout
93 #:with-timeout)
95 (:documentation "BORDEAUX-THREADS is a proposed standard for a minimal
96 MP/threading interface. It is similar to the CLIM-SYS threading and
97 lock support, but for the following broad differences:
99 1) Some behaviours are defined in additional detail: attention has
100 been given to special variable interaction, whether and when
101 cleanup forms are run. Some behaviours are defined in less
102 detail: an implementation that does not support multiple
103 threads is not required to use a new list (nil) for a lock, for
104 example.
106 2) Many functions which would be difficult, dangerous or inefficient
107 to provide on some implementations have been removed. Chiefly
108 these are functions such as thread-wait which expect for
109 efficiency that the thread scheduler is written in Lisp and
110 'hookable', which can't sensibly be done if the scheduler is
111 external to the Lisp image, or the system has more than one CPU.
113 3) Unbalanced ACQUIRE-LOCK and RELEASE-LOCK functions have been
114 added.
116 4) Posix-style condition variables have been added, as it's not
117 otherwise possible to implement them correctly using the other
118 operations that are specified.
120 Threads may be implemented using whatever applicable techniques are
121 provided by the operating system: user-space scheduling,
122 kernel-based LWPs or anything else that does the job.
124 To avoid conflict with existing MP/threading interfaces in
125 implementations, these symbols live in the BORDEAUX-THREADS-2 package.
126 Implementations and/or users may also make them visible or exported
127 in other more traditionally named packages."))