;;; -*-Scheme-*-
;;;
-;;; $Id: editor.scm,v 1.250 2001/05/31 19:41:53 cph Exp $
+;;; $Id: editor.scm,v 1.251 2001/05/31 19:56:37 cph Exp $
;;;
;;; Copyright (c) 1986, 1989-2001 Massachusetts Institute of Technology
;;;
(weak-set-cdr! (car threads) #f))
(loop (cdr threads) threads)))))))
+(define (start-standard-polling-thread interval output-processor)
+ (let ((holder (list #f)))
+ (set-car! holder
+ (register-inferior-thread!
+ (let ((thread
+ (create-thread editor-thread-root-continuation
+ (lambda ()
+ (do () (#f)
+ (let ((registration (car holder)))
+ (cond ((eq? registration 'KILL-THREAD)
+ (exit-current-thread unspecific))
+ (registration
+ (inferior-thread-output! registration))))
+ (sleep-current-thread interval))))))
+ (detach-thread thread)
+ thread)
+ output-processor))
+ holder))
+
+(define (stop-standard-polling-thread holder)
+ (without-interrupts
+ (lambda ()
+ (let ((registration (car holder)))
+ (if (and registration (not (eq? registration 'KILL-THREAD)))
+ (deregister-inferior-thread! registration)))
+ (set-car! holder 'KILL-THREAD))))
+\f
(define (inferior-thread-output! flags)
(without-interrupts (lambda () (inferior-thread-output!/unsafe flags))))
;;; -*-Scheme-*-
;;;
-;;; $Id: notify.scm,v 1.19 2001/01/06 02:36:20 cph Exp $
+;;; $Id: notify.scm,v 1.20 2001/05/31 19:57:23 cph Exp $
;;;
;;; Copyright (c) 1992-2001 Massachusetts Institute of Technology
;;;
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
-;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;;; 02111-1307, USA.
;;;; Mode-line notifications (e.g. presence of mail, load average)
(define notifier-mail-string "")
(define override-notifier-mail-string #f)
(define mail-notify-hook-installed? #f)
-(define current-notifier-thread #f)
(define notifier-thread-registration #f)
\f
(define-command run-notifier
unspecific))
((ref-command kill-notifier))
(set-variable! global-mode-string `("" ,notifier:get-string))
- (let ((thread
- (create-thread
- editor-thread-root-continuation
- (lambda ()
- (do () (#f)
- (if notifier-thread-registration
- (inferior-thread-output! notifier-thread-registration))
- (sleep-current-thread
- (* 1000 (ref-variable notify-interval))))))))
- (detach-thread thread)
- (set! current-notifier-thread thread)
- (set! notifier-thread-registration
- (register-inferior-thread! thread notifier)))
+ (set! notifier-thread-registration
+ (start-standard-polling-thread (* (ref-variable notify-interval #f)
+ 1000)
+ notifier))
unspecific))
(define (notifier)
(lambda ()
(without-interrupts
(lambda ()
- (if current-notifier-thread
- (begin
- (if (not (thread-dead? current-notifier-thread))
- (signal-thread-event current-notifier-thread
- (lambda ()
- (exit-current-thread unspecific))))
- (set! current-notifier-thread #f)))
(if notifier-thread-registration
(begin
- (deregister-inferior-thread! notifier-thread-registration)
- (set! notifier-thread-registration #f)))
- unspecific))
+ (stop-standard-polling-thread notifier-thread-registration)
+ (set! notifier-thread-registration #f)
+ unspecific))))
(update-notifier-strings! "" "")
(set-variable! global-mode-string override-notifier-mail-string #f)))
\ No newline at end of file
;;; -*-Scheme-*-
;;;
-;;; $Id: imail-top.scm,v 1.257 2001/05/29 19:32:39 cph Exp $
+;;; $Id: imail-top.scm,v 1.258 2001/05/31 19:57:40 cph Exp $
;;;
;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology
;;;
(define (start-probe-folder-thread buffer)
(stop-probe-folder-thread buffer)
- (let ((folder (buffer-get buffer 'IMAIL-FOLDER #f))
- (interval (ref-variable imail-update-interval #f)))
- (if (and folder interval
- (not (get-property folder 'PROBE-REGISTRATION #f)))
- (let ((holder (list #f)))
- (set-car! holder
- (register-inferior-thread!
- (let ((thread
- (create-thread
- editor-thread-root-continuation
- (probe-folder-thread holder
- (* 1000 interval)))))
- (detach-thread thread)
- thread)
- (probe-folder-output-processor
- (weak-cons folder unspecific))))
- (store-property! folder 'PROBE-REGISTRATION holder)))))
-
-(define ((probe-folder-thread holder interval))
- (do () (#f)
- (let ((registration (car holder)))
- (cond ((eq? registration 'KILL-THREAD) (exit-current-thread unspecific))
- (registration (inferior-thread-output! registration))))
- (sleep-current-thread interval)))
+ (without-interrupts
+ (lambda ()
+ (let ((folder (buffer-get buffer 'IMAIL-FOLDER #f))
+ (interval (ref-variable imail-update-interval #f)))
+ (if (and folder interval
+ (not (get-property folder 'PROBE-REGISTRATION #f)))
+ (store-property! folder
+ 'PROBE-REGISTRATION
+ (start-standard-output-polling-thread
+ (* 1000 interval)
+ (probe-folder-output-processor
+ (weak-cons folder unspecific)))))))))
(define ((probe-folder-output-processor folder))
(let ((folder (weak-car folder)))
(begin
(let ((holder (get-property folder 'PROBE-REGISTRATION #f)))
(if holder
- (begin
- (let ((registration (car holder)))
- (if (and registration
- (not (eq? registration 'KILL-THREAD)))
- (deregister-inferior-thread! registration)))
- (set-car! holder 'KILL-THREAD))))
+ (stop-standard-output-polling-thread holder)))
(remove-property! folder 'PROBE-REGISTRATION)))))))
\f
;;;; Message insertion procedures