/[slime]/slime/swank-backend.lisp
ViewVC logotype

Contents of /slime/swank-backend.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.59 - (hide annotations)
Fri Jul 2 23:50:09 2004 UTC (9 years, 9 months ago) by lgorrie
Branch: MAIN
Changes since 1.58: +1 -5 lines
(definterface): Don't use NO-APPLICABLE-METHOD for detail
methods. Instead just define them as regular methods with all argument
types being T. Defimplementation will then replace them by using the
same signature. N-A-M was a stupid idea!
1 lgorrie 1.1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil; outline-regexp: ";;;;;*" -*-
2     ;;;
3 lgorrie 1.13 ;;; slime-backend.lisp --- SLIME backend interface.
4 lgorrie 1.1 ;;;
5 lgorrie 1.13 ;;; Created by James Bielman in 2003. Released into the public domain.
6 lgorrie 1.1 ;;;
7 lgorrie 1.13 ;;; This file defines the functions that must be implemented
8     ;;; separately for each Lisp. Each is declared as a generic function
9     ;;; for which swank-<implementation>.lisp provides methods.
10 lgorrie 1.1
11 heller 1.36 (defpackage :swank-backend
12 lgorrie 1.1 (:use :common-lisp)
13 heller 1.36 (:export #:sldb-condition
14     #:original-condition
15     #:compiler-condition
16     #:message
17     #:short-message
18     #:condition
19     #:severity
20     #:location
21     #:location-p
22     #:location-buffer
23     #:location-position
24     #:position-p
25     #:position-pos
26     #:print-output-to-string
27 mbaringer 1.42 #:quit-lisp
28 lgorrie 1.56 #:unbound-slot-filler))
29 lgorrie 1.1
30 heller 1.36 (in-package :swank-backend)
31 lgorrie 1.1
32    
33 lgorrie 1.21 ;;;; Metacode
34    
35     (defparameter *interface-functions* '()
36     "The names of all interface functions.")
37    
38     (defparameter *unimplemented-interfaces* '()
39     "List of interface functions that are not implemented.
40     DEFINTERFACE adds to this list and DEFIMPLEMENTATION removes.")
41    
42 heller 1.52 (defmacro definterface (name args documentation &rest default-body)
43 lgorrie 1.21 "Define an interface function for the backend to implement.
44     A generic function is defined with NAME, ARGS, and DOCUMENTATION.
45    
46     If a DEFAULT-BODY is supplied then NO-APPLICABLE-METHOD is specialized
47     to execute the body if the backend doesn't provide a specific
48     implementation.
49    
50     Backends implement these functions using DEFIMPLEMENTATION."
51 lgorrie 1.43 (check-type documentation string "a documentation string")
52 lgorrie 1.21 (flet ((gen-default-impl ()
53     (let ((received-args (gensym "ARGS-")))
54 lgorrie 1.59 `(defmethod ,name ,args ,@default-body))))
55 lgorrie 1.48 `(progn (defgeneric ,name ,args (:documentation ,documentation))
56     (pushnew ',name *interface-functions*)
57     ,(if (null default-body)
58     `(pushnew ',name *unimplemented-interfaces*)
59     (gen-default-impl))
60     ;; see <http://www.franz.com/support/documentation/6.2/doc/pages/variables/compiler/s_cltl1-compile-file-toplevel-compatibility-p_s.htm>
61     (eval-when (:compile-toplevel :load-toplevel :execute)
62     (export ',name :swank-backend))
63     ',name)))
64 lgorrie 1.21
65     (defmacro defimplementation (name args &body body)
66 heller 1.25 `(progn (defmethod ,name ,args ,@body)
67     (if (member ',name *interface-functions*)
68     (setq *unimplemented-interfaces*
69     (remove ',name *unimplemented-interfaces*))
70     (warn "DEFIMPLEMENTATION of undefined interface (~S)" ',name))
71     ',name))
72 lgorrie 1.21
73     (defun warn-unimplemented-interfaces ()
74     "Warn the user about unimplemented backend features.
75     The portable code calls this function at startup."
76     (warn "These Swank interfaces are unimplemented:~% ~A"
77     (sort (copy-list *unimplemented-interfaces*) #'string<)))
78    
79    
80 heller 1.46 ;;;; Utilities
81    
82     (defmacro with-struct ((conc-name &rest names) obj &body body)
83     "Like with-slots but works only for structs."
84     (flet ((reader (slot) (intern (concatenate 'string
85     (symbol-name conc-name)
86     (symbol-name slot))
87     (symbol-package conc-name))))
88     (let ((tmp (gensym "OO-")))
89     ` (let ((,tmp ,obj))
90     (symbol-macrolet
91     ,(loop for name in names collect
92     (typecase name
93     (symbol `(,name (,(reader name) ,tmp)))
94     (cons `(,(first name) (,(reader (second name)) ,tmp)))
95     (t (error "Malformed syntax in WITH-STRUCT: ~A" name))))
96     ,@body)))))
97 lgorrie 1.54
98    
99 lgorrie 1.13 ;;;; TCP server
100    
101 heller 1.29 (definterface create-socket (host port)
102     "Create a listening TCP socket on interface HOST and port PORT .")
103 lgorrie 1.13
104 lgorrie 1.21 (definterface local-port (socket)
105     "Return the local port number of SOCKET.")
106 lgorrie 1.1
107 lgorrie 1.21 (definterface close-socket (socket)
108     "Close the socket SOCKET.")
109 lgorrie 1.1
110 lgorrie 1.21 (definterface accept-connection (socket)
111 heller 1.16 "Accept a client connection on the listening socket SOCKET. Return
112 lgorrie 1.21 a stream for the new connection.")
113 heller 1.16
114 heller 1.31 (definterface add-sigio-handler (socket fn)
115 lgorrie 1.21 "Call FN whenever SOCKET is readable.")
116 heller 1.16
117 heller 1.31 (definterface remove-sigio-handlers (socket)
118     "Remove all sigio handlers for SOCKET.")
119    
120     (definterface add-fd-handler (socket fn)
121     "Call FN when Lisp is waiting for input and SOCKET is readable.")
122    
123     (definterface remove-fd-handlers (socket)
124     "Remove all fd-handlers for SOCKET.")
125 heller 1.18
126 heller 1.36 (definterface preferred-communication-style ()
127     "Return one of the symbols :spawn, :sigio, :fd-handler, or NIL."
128     nil)
129    
130 lgorrie 1.13 ;;; Base condition for networking errors.
131 msimmons 1.50 (define-condition network-error (simple-error) ())
132 lgorrie 1.13
133 heller 1.53 (definterface emacs-connected (stream)
134 lgorrie 1.13 "Hook called when the first connection from Emacs is established.
135     Called from the INIT-FN of the socket server that accepts the
136     connection.
137 lgorrie 1.1
138 lgorrie 1.13 This is intended for setting up extra context, e.g. to discover
139 heller 1.53 that the calling thread is the one that interacts with Emacs.
140    
141     STREAM is the redirected user output stream to Emacs. This is passed
142     so that the backend can apply buffer flushing magic."
143     nil)
144 lgorrie 1.1
145    
146 heller 1.20 ;;;; Unix signals
147    
148     (defconstant +sigint+ 2)
149    
150 heller 1.36 (definterface call-without-interrupts (fn)
151     "Call FN in a context where interrupts are disabled."
152     (funcall fn))
153 heller 1.20
154 heller 1.32 (definterface getpid ()
155     "Return the (Unix) process ID of this superior Lisp.")
156    
157     (definterface lisp-implementation-type-name ()
158     "Return a short name for the Lisp implementation."
159     (lisp-implementation-type))
160 heller 1.20
161 heller 1.51 (definterface default-directory ()
162     "Return the default directory."
163     (directory-namestring (truename *default-pathname-defaults*)))
164    
165 heller 1.39 (definterface set-default-directory (directory)
166     "Set the default directory.
167     This is used to resolve filenames without directory component."
168     (setf *default-pathname-defaults* (truename (merge-pathnames directory)))
169 heller 1.51 (default-directory))
170    
171     (definterface call-with-syntax-hooks (fn)
172     "Call FN with hooks to handle special syntax."
173     (funcall fn))
174 heller 1.39
175 heller 1.52 (definterface default-readtable-alist ()
176     "Return a suitable initial value for SWANK:*READTABLE-ALIST*."
177     '())
178    
179 heller 1.58 (definterface quit-lisp ()
180     "Exit the current lisp image.")
181    
182 heller 1.20
183 lgorrie 1.1 ;;;; Compilation
184 dbarlow 1.8
185 lgorrie 1.21 (definterface call-with-compilation-hooks (func)
186 lgorrie 1.47 "Call FUNC with hooks to record compiler conditions.")
187 lgorrie 1.13
188 vsedach 1.14 (defmacro with-compilation-hooks ((&rest ignore) &body body)
189 lgorrie 1.47 "Execute BODY as in CALL-WITH-COMPILATION-HOOKS."
190 vsedach 1.14 (declare (ignore ignore))
191 dbarlow 1.8 `(call-with-compilation-hooks (lambda () (progn ,@body))))
192 lgorrie 1.1
193 heller 1.36 (definterface swank-compile-string (string &key buffer position)
194 lgorrie 1.47 "Compile source from STRING. During compilation, compiler
195 lgorrie 1.1 conditions must be trapped and resignalled as COMPILER-CONDITIONs.
196    
197     If supplied, BUFFER and POSITION specify the source location in Emacs.
198    
199     Additionally, if POSITION is supplied, it must be added to source
200 lgorrie 1.21 positions reported in compiler conditions.")
201 lgorrie 1.1
202 lgorrie 1.43 (definterface operate-on-system (system-name operation-name &rest keyword-args)
203     "Perform OPERATION-NAME on SYSTEM-NAME using ASDF.
204     The KEYWORD-ARGS are passed on to the operation.
205     Example:
206     \(operate-on-system \"SWANK\" \"COMPILE-OP\" :force t)"
207     (unless (member :asdf *features*)
208     (error "ASDF is not loaded."))
209 heller 1.30 (with-compilation-hooks ()
210 lgorrie 1.43 (let ((operate (find-symbol "OPERATE" :asdf))
211     (operation (find-symbol operation-name :asdf)))
212     (when (null operation)
213     (error "Couldn't find ASDF operation ~S" operation-name))
214     (apply operate operation system-name keyword-args))))
215 mbaringer 1.26
216 heller 1.36 (definterface swank-compile-file (filename load-p)
217 lgorrie 1.1 "Compile FILENAME signalling COMPILE-CONDITIONs.
218 lgorrie 1.21 If LOAD-P is true, load the file after compilation.")
219 lgorrie 1.1
220 lgorrie 1.13 (deftype severity () '(member :error :warning :style-warning :note))
221    
222     ;; Base condition type for compiler errors, warnings and notes.
223     (define-condition compiler-condition (condition)
224     ((original-condition
225     ;; The original condition thrown by the compiler if appropriate.
226     ;; May be NIL if a compiler does not report using conditions.
227     :type (or null condition)
228     :initarg :original-condition
229     :accessor original-condition)
230    
231     (severity :type severity
232     :initarg :severity
233     :accessor severity)
234    
235     (message :initarg :message
236     :accessor message)
237    
238 heller 1.30 (short-message :initarg :short-message
239     :initform nil
240     :accessor short-message)
241    
242 lgorrie 1.13 (location :initarg :location
243     :accessor location)))
244 heller 1.30
245 lgorrie 1.17
246 lgorrie 1.13 ;;;; Streams
247    
248 lgorrie 1.21 (definterface make-fn-streams (input-fn output-fn)
249 lgorrie 1.13 "Return character input and output streams backended by functions.
250     When input is needed, INPUT-FN is called with no arguments to
251     return a string.
252     When output is ready, OUTPUT-FN is called with the output as its
253     argument.
254    
255     Output should be forced to OUTPUT-FN before calling INPUT-FN.
256    
257 lgorrie 1.21 The streams are returned as two values.")
258 lgorrie 1.13
259 lgorrie 1.1
260     ;;;; Documentation
261    
262 heller 1.36 (definterface arglist (name)
263     "Return the lambda list for the symbol NAME.
264    
265 heller 1.44 The result can be a list or the :not-available if the arglist cannot
266     be determined.")
267 lgorrie 1.1
268 lgorrie 1.21 (definterface macroexpand-all (form)
269 lgorrie 1.1 "Recursively expand all macros in FORM.
270 lgorrie 1.21 Return the resulting form.")
271 lgorrie 1.1
272 lgorrie 1.21 (definterface describe-symbol-for-emacs (symbol)
273 lgorrie 1.1 "Return a property list describing SYMBOL.
274    
275     The property list has an entry for each interesting aspect of the
276     symbol. The recognised keys are:
277    
278     :VARIABLE :FUNCTION :SETF :TYPE :CLASS :MACRO :COMPILER-MACRO
279     :ALIEN-TYPE :ALIEN-STRUCT :ALIEN-UNION :ALIEN-ENUM
280    
281     The value of each property is the corresponding documentation string,
282     or :NOT-DOCUMENTED. It is legal to include keys not listed here.
283    
284     Properties should be included if and only if they are applicable to
285     the symbol. For example, only (and all) fbound symbols should include
286     the :FUNCTION property.
287    
288     Example:
289     \(describe-symbol-for-emacs 'vector)
290     => (:CLASS :NOT-DOCUMENTED
291     :TYPE :NOT-DOCUMENTED
292 lgorrie 1.21 :FUNCTION \"Constructs a simple-vector from the given objects.\")")
293    
294     (definterface describe-definition (name type)
295     "Describe the definition NAME of TYPE.
296     TYPE can be any value returned by DESCRIBE-SYMBOL-FOR-EMACS.
297    
298     Return a documentation string, or NIL if none is available.")
299 lgorrie 1.2
300    
301     ;;;; Debugging
302    
303 lgorrie 1.21 (definterface call-with-debugging-environment (debugger-loop-fn)
304 lgorrie 1.2 "Call DEBUGGER-LOOP-FN in a suitable debugging environment.
305    
306     This function is called recursively at each debug level to invoke the
307     debugger loop. The purpose is to setup any necessary environment for
308     other debugger callbacks that will be called within the debugger loop.
309    
310     For example, this is a reasonable place to compute a backtrace, switch
311 lgorrie 1.21 to safe reader/printer settings, and so on.")
312 lgorrie 1.2
313     (define-condition sldb-condition (condition)
314     ((original-condition
315     :initarg :original-condition
316 heller 1.5 :accessor original-condition))
317 lgorrie 1.2 (:documentation
318     "Wrapper for conditions that should not be debugged.
319    
320     When a condition arises from the internals of the debugger, it is not
321     desirable to debug it -- we'd risk entering an endless loop trying to
322     debug the debugger! Instead, such conditions can be reported to the
323     user without (re)entering the debugger by wrapping them as
324     `sldb-condition's."))
325    
326 heller 1.36 (definterface compute-backtrace (start end)
327 lgorrie 1.3 "Return a list containing a backtrace of the condition current
328     being debugged. The results are unspecified if this function is
329 heller 1.36 called outside the dynamic contour CALL-WITH-DEBUGGING-ENVIRONMENT.
330    
331     START and END are zero-based indices constraining the number of frames
332     returned. Frame zero is defined as the frame which invoked the
333     debugger. If END is nil, return the frames from START to the end of
334     the stack.")
335 lgorrie 1.3
336 heller 1.36 (definterface print-frame (frame stream)
337     "Print frame to stream.")
338 lgorrie 1.3
339 lgorrie 1.21 (definterface frame-source-location-for-emacs (frame-number)
340     "Return the source location for FRAME-NUMBER.")
341 lgorrie 1.3
342 lgorrie 1.21 (definterface frame-catch-tags (frame-number)
343 lgorrie 1.3 "Return a list of XXX list of what? catch tags for a debugger
344     stack frame. The results are undefined unless this is called
345     within the dynamic contour of a function defined by
346 lgorrie 1.21 DEFINE-DEBUGGER-HOOK.")
347 lgorrie 1.3
348 lgorrie 1.21 (definterface frame-locals (frame-number)
349 heller 1.57 "Return a list of XXX local variable designators define me
350 lgorrie 1.3 for a debugger stack frame. The results are undefined unless
351     this is called within the dynamic contour of a function defined
352 lgorrie 1.21 by DEFINE-DEBUGGER-HOOK.")
353 heller 1.37
354 heller 1.57 (definterface frame-var-value (frame var)
355     "Return the value of VAR in FRAME.
356     FRAME is the number of the frame in the backtrace.
357     VAR is the number of the variable in the frame.")
358    
359 heller 1.37 (definterface disassemble-frame (frame-number)
360     "Disassemble the code for the FRAME-NUMBER.
361     The output should be written to standard output.
362     FRAME-NUMBER is a non-negative interger.")
363    
364 lgorrie 1.21 (definterface eval-in-frame (form frame-number)
365 lgorrie 1.3 "Evaluate a Lisp form in the lexical context of a stack frame
366     in the debugger. The results are undefined unless called in the
367     dynamic contour of a function defined by DEFINE-DEBUGGER-HOOK.
368    
369     FRAME-NUMBER must be a positive integer with 0 indicating the
370     frame which invoked the debugger.
371    
372     The return value is the result of evaulating FORM in the
373 lgorrie 1.21 appropriate context.")
374 heller 1.22
375     (definterface return-from-frame (frame-number form)
376     "Unwind the stack to the frame FRAME-NUMBER and return the value(s)
377     produced by evaluating FORM in the frame context to its caller.
378    
379     Execute any clean-up code from unwind-protect forms above the frame
380     during unwinding.
381    
382     Return a string describing the error if it's not possible to return
383     from the frame.")
384    
385     (definterface restart-frame (frame-number)
386     "Restart execution of the frame FRAME-NUMBER with the same arguments
387     as it was called originally.")
388 lgorrie 1.3
389 lgorrie 1.49 (definterface format-sldb-condition (condition)
390     "Format a condition for display in SLDB."
391     (princ-to-string condition))
392    
393     (definterface condition-references (condition)
394     "Return a list of documentation references for a condition.
395     Each reference is one of:
396     (:ANSI-CL
397     {:FUNCTION | :SPECIAL-OPERATOR | :MACRO | :SECTION | :GLOSSARY }
398     symbol-or-name)
399     (:SBCL :NODE node-name)"
400     '())
401 heller 1.52
402     (definterface sldb-step (frame-number)
403     "Step to the next code location in the frame FRAME-NUMBER.")
404    
405 lgorrie 1.49
406 lgorrie 1.3
407 heller 1.36 ;;;; Definition finding
408    
409     (defstruct (:location (:type list) :named
410 lgorrie 1.45 (:constructor make-location
411     (buffer position &optional hints)))
412     buffer position
413     ;; Hints is a property list optionally containing:
414     ;; :snippet SOURCE-TEXT
415     ;; This is a snippet of the actual source text at the start of
416     ;; the definition, which could be used in a text search.
417     hints)
418 heller 1.36
419     (defstruct (:error (:type list) :named (:constructor)) message)
420     (defstruct (:file (:type list) :named (:constructor)) name)
421     (defstruct (:buffer (:type list) :named (:constructor)) name)
422     (defstruct (:position (:type list) :named (:constructor)) pos)
423    
424     (definterface find-definitions (name)
425     "Return a list ((DSPEC LOCATION) ...) for NAME's definitions.
426    
427 heller 1.38 NAME is a \"definition specifier\".
428 heller 1.36
429 heller 1.38 DSPEC is a \"definition specifier\" describing the
430 heller 1.36 definition, e.g., FOO or (METHOD FOO (STRING NUMBER)) or
431 heller 1.38 \(DEFVAR FOO).
432    
433     LOCATION is the source location for the definition.")
434 heller 1.36
435    
436     ;;;; XREF
437    
438     (definterface who-calls (function-name)
439     "Return the call sites of FUNCTION-NAME (a symbol).
440     The results is a list ((DSPEC LOCATION) ...).")
441    
442     (definterface who-references (variable-name)
443     "Return the locations where VARIABLE-NAME (a symbol) is referenced.
444     See WHO-CALLS for a description of the return value.")
445    
446     (definterface who-binds (variable-name)
447     "Return the locations where VARIABLE-NAME (a symbol) is bound.
448     See WHO-CALLS for a description of the return value.")
449    
450     (definterface who-sets (variable-name)
451     "Return the locations where VARIABLE-NAME (a symbol) is set.
452     See WHO-CALLS for a description of the return value.")
453    
454     (definterface who-macroexpands (macro-name)
455     "Return the locations where MACRO-NAME (a symbol) is expanded.
456     See WHO-CALLS for a description of the return value.")
457    
458     (definterface who-specializes (class-name)
459     "Return the locations where CLASS-NAME (a symbol) is specialized.
460     See WHO-CALLS for a description of the return value.")
461    
462     ;;; Simpler variants.
463    
464     (definterface list-callers (function-name)
465     "List the callers of FUNCTION-NAME.
466     This function is like WHO-CALLS except that it is expected to use
467     lower-level means. Whereas WHO-CALLS is usually implemented with
468     special compiler support, LIST-CALLERS is usually implemented by
469     groveling for constants in function objects throughout the heap.
470    
471     The return value is as for WHO-CALLS.")
472    
473     (definterface list-callees (function-name)
474     "List the functions called by FUNCTION-NAME.
475     See LIST-CALLERS for a description of the return value.")
476    
477    
478 heller 1.23 ;;;; Profiling
479    
480     ;;; The following functions define a minimal profiling interface.
481    
482     (definterface profile (fname)
483     "Marks symbol FNAME for profiling.")
484    
485     (definterface profiled-functions ()
486     "Returns a list of profiled functions.")
487    
488     (definterface unprofile (fname)
489     "Marks symbol FNAME as not profiled.")
490    
491     (definterface unprofile-all ()
492     "Marks all currently profiled functions as not profiled."
493     (dolist (f (profiled-functions))
494     (unprofile f)))
495    
496     (definterface profile-report ()
497     "Prints profile report.")
498    
499     (definterface profile-reset ()
500     "Resets profile counters.")
501    
502     (definterface profile-package (package callers-p methods)
503     "Wrap profiling code around all functions in PACKAGE. If a function
504     is already profiled, then unprofile and reprofile (useful to notice
505     function redefinition.)
506    
507     If CALLERS-P is T names have counts of the most common calling
508     functions recorded.
509    
510     When called with arguments :METHODS T, profile all methods of all
511     generic functions having names in the given package. Generic functions
512     themselves, that is, their dispatch functions, are left alone.")
513    
514    
515 heller 1.19 ;;;; Inspector
516 lgorrie 1.56
517 heller 1.57 (defstruct (unbound-slot-filler (:print-function print-unbound-slot))
518 lgorrie 1.56 "The definition of an object which serves as a placeholder in
519     an unbound slot for inspection purposes.")
520 heller 1.57
521     (defun print-unbound-slot (o stream depth)
522     (declare (ignore depth))
523     (print-unreadable-object (o stream :type t)))
524 heller 1.19
525 heller 1.35 (definterface inspected-parts (object)
526     "Return a short description and a list of (LABEL . VALUE) pairs."
527     (values (format nil "~S is an atom." object) '()))
528 heller 1.19
529 heller 1.29 (definterface describe-primitive-type (object)
530 heller 1.35 "Return a string describing the primitive type of object."
531 heller 1.36 (declare (ignore object))
532 heller 1.35 "N/A")
533 heller 1.19
534    
535 heller 1.36 ;;;; Multithreading
536 lgorrie 1.21 ;;;
537     ;;; The default implementations are sufficient for non-multiprocessing
538     ;;; implementations.
539 lgorrie 1.9
540 lgorrie 1.21 (definterface startup-multiprocessing ()
541 lgorrie 1.9 "Initialize multiprocessing, if necessary.
542    
543     This function is called directly through the listener, not in an RPC
544     from Emacs. This is to support interfaces such as CMUCL's
545     MP::STARTUP-IDLE-AND-TOP-LEVEL-LOOPS which does not return like a
546 lgorrie 1.21 normal function."
547     nil)
548 lgorrie 1.9
549 lgorrie 1.21 (definterface spawn (fn &key name)
550     "Create a new thread to call FN.")
551 lgorrie 1.17
552 heller 1.58 (definterface thread-id (thread)
553     "Return an Emacs-parsable object to identify THREAD.
554    
555     Ids should be comparable with equal, i.e.:
556     (equal (thread-id <t1>) (thread-id <t2>)) <==> (eq <t1> <t2>)")
557    
558     (definterface find-thread (id)
559     "Return the thread for ID.
560     ID should be an id previously obtained with THREAD-ID.
561     Can return nil if the thread no longer exists.")
562    
563 heller 1.28 (definterface thread-name (thread)
564     "Return the name of THREAD.
565 lgorrie 1.9
566     Thread names are be single-line strings and are meaningful to the
567 lgorrie 1.21 user. They do not have to be unique."
568 heller 1.28 (declare (ignore thread))
569 lgorrie 1.21 "The One True Thread")
570 lgorrie 1.9
571 heller 1.28 (definterface thread-status (thread)
572     "Return a string describing THREAD's state."
573     (declare (ignore thread))
574     "")
575    
576 lgorrie 1.21 (definterface make-lock (&key name)
577 lgorrie 1.17 "Make a lock for thread synchronization.
578 lgorrie 1.21 Only one thread may hold the lock (via CALL-WITH-LOCK-HELD) at a time."
579 heller 1.23 (declare (ignore name))
580 lgorrie 1.21 :null-lock)
581 lgorrie 1.9
582 lgorrie 1.21 (definterface call-with-lock-held (lock function)
583     "Call FUNCTION with LOCK held, queueing if necessary."
584 heller 1.24 (declare (ignore lock)
585     (type function function))
586 lgorrie 1.21 (funcall function))
587 heller 1.25
588     (definterface current-thread ()
589     "Return the currently executing thread."
590     0)
591 heller 1.28
592     (definterface all-threads ()
593     "Return a list of all threads.")
594    
595     (definterface thread-alive-p (thread)
596 heller 1.35 "Test if THREAD is termintated."
597     (member thread (all-threads)))
598 heller 1.25
599     (definterface interrupt-thread (thread fn)
600     "Cause THREAD to execute FN.")
601    
602 mbaringer 1.34 (definterface kill-thread (thread)
603     "Kill THREAD."
604     (declare (ignore thread))
605     nil)
606    
607 heller 1.25 (definterface send (thread object)
608     "Send OBJECT to thread THREAD.")
609    
610     (definterface receive ()
611     "Return the next message from current thread's mailbox.")

  ViewVC Help
Powered by ViewVC 1.1.5