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

Contents of /slime/swank-backend.lisp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5