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

Diff of /slime/swank-backend.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.151 by trittweiler, Fri Sep 12 12:27:38 2008 UTC revision 1.152 by heller, Sun Sep 14 17:10:34 2008 UTC
# Line 1027  but that thread may hold it more than on Line 1027  but that thread may hold it more than on
1027  (definterface receive-if (predicate &optional timeout)  (definterface receive-if (predicate &optional timeout)
1028    "Return the first message satisfiying PREDICATE.")    "Return the first message satisfiying PREDICATE.")
1029    
1030  (defvar *pending-slime-interrupts*)  (defvar *pending-slime-interrupts* '())
1031    
1032  (defun check-slime-interrupts ()  (defun check-slime-interrupts ()
1033    "Execute pending interrupts if any.    "Execute pending interrupts if any.
1034  This should be called periodically in operations which  This should be called periodically in operations which
1035  can take a long time to complete."  can take a long time to complete."
1036    (when (and (boundp '*pending-slime-interrupts*)    (when (and *pending-slime-interrupts*)
              *pending-slime-interrupts*)  
1037      (funcall (pop *pending-slime-interrupts*))))      (funcall (pop *pending-slime-interrupts*))))
1038    
1039    (definterface wait-for-input (streams &optional timeout)
1040      "Wait for input on a list of streams.  Return those that are ready.
1041    STREAMS is a list of streams
1042    TIMEOUT nil, t, or real number. If TIMEOUT is t, return
1043    those streams which are ready immediately, without waiting.
1044    If TIMEOUT is a number and no streams is ready after TIMEOUT seconds,
1045    return nil.
1046    
1047    Return :interrupt if an interrupt occurs while waiting."
1048      (assert (= (length streams) 1))
1049      (let ((stream (car streams)))
1050        (case timeout
1051          ((nil)
1052           (cond (*pending-slime-interrupts* :interrupt)
1053                 (t (peek-char nil stream nil nil)
1054                    streams)))
1055          ((t)
1056           (let ((c (read-char-no-hang stream nil nil)))
1057             (cond (c
1058                    (unread-char c stream)
1059                    streams)
1060                   (t '()))))
1061          (t
1062           (loop
1063            (if *pending-slime-interrupts* (return :interrupt))
1064            (when (wait-for-input streams t) (return streams))
1065            (sleep 0.1)
1066            (when (<= (decf timeout 0.1) 0) (return nil)))))))
1067    
1068  (definterface toggle-trace (spec)  (definterface toggle-trace (spec)
1069    "Toggle tracing of the function(s) given with SPEC.    "Toggle tracing of the function(s) given with SPEC.
1070  SPEC can be:  SPEC can be:

Legend:
Removed from v.1.151  
changed lines
  Added in v.1.152

  ViewVC Help
Powered by ViewVC 1.1.5