Add optional argument NO-DEFER? to CLOSE-RESOURCE. If this argument
authorChris Hanson <org/chris-hanson/cph>
Sun, 3 Jun 2001 01:22:54 +0000 (01:22 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sun, 3 Jun 2001 01:22:54 +0000 (01:22 +0000)
is true, it tells the operation that the resource must be closed
immediately.  Otherwise, the operation may defer the closure.

v7/src/imail/imail-core.scm
v7/src/imail/imail-file.scm
v7/src/imail/imail-imap.scm

index 9e254e51a4e3f13c5924c9192dd7ad4fd188519c..e6594a672da5ea1300fd9504c26cf92f0b0df251 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-core.scm,v 1.140 2001/05/29 20:36:34 cph Exp $
+;;; $Id: imail-core.scm,v 1.141 2001/06/03 01:22:31 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology
 ;;;
 ;; -------------------------------------------------------------------
 ;; Close RESOURCE, freeing up connections, memory, etc.  Subsequent use
 ;; of the resource must work, but may incur a significant time or space
-;; penalty.
+;; penalty.  Optional argument NO-DEFER? means that the resource must
+;; be closed immediately, and not deferred.
 
-(define (close-resource resource)
+(define (close-resource resource #!optional no-defer?)
   (save-resource resource)
-  (%close-resource resource))
+  (%close-resource resource (if (default-object? no-defer?) #f no-defer?)))
 
-(define-generic %close-resource (resource))
+(define-generic %close-resource (resource no-defer?))
 
 ;; -------------------------------------------------------------------
 ;; Return the number of messages in FOLDER.
index 633fc39935da9b5f5c647db1227fadd7264f107e..025c07845d9b907ae0664063e64b495ab9bf239d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-file.scm,v 1.75 2001/05/29 20:36:40 cph Exp $
+;;; $Id: imail-file.scm,v 1.76 2001/06/03 01:22:54 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology
 ;;;
 (define (file-folder-pathname folder)
   (pathname-url-pathname (resource-locator folder)))
 
-(define-method %close-resource ((folder <file-folder>))
+(define-method %close-resource ((folder <file-folder>) no-defer?)
+  no-defer?
   (discard-file-folder-messages folder)
   (discard-file-folder-xstring folder))
 
 (define-method %open-resource ((url <directory-url>))
   (make-file-container url))
 
-(define-method %close-resource ((container <file-container>))
-  container
+(define-method %close-resource ((container <file-container>) no-defer?)
+  container no-defer?
   unspecific)
 
 (define-method save-resource ((container <file-container>))
index 88a84724509d710e973b9f18755a1a63826ec0a6..7afeeb9a14701a877c194fe2c7bdbf06be8acd51 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-imap.scm,v 1.175 2001/06/01 02:20:53 cph Exp $
+;;; $Id: imail-imap.scm,v 1.176 2001/06/03 01:22:45 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology
 ;;;
                  (lambda ()
                    (guarantee-imap-connection-open connection)
                    (let ((v (receiver connection)))
-                     (maybe-close-imap-connection connection 1)
+                     (maybe-close-imap-connection connection 1 #f)
                      v))
                  (lambda ()
                    (decrement-connection-reference-count! connection)))))
        (close-port port)))
   (reset-imap-connection connection))
 \f
-(define (maybe-close-imap-connection connection min-count)
+(define (maybe-close-imap-connection connection min-count no-defer?)
   (if (= (imap-connection-reference-count connection) min-count)
-      (if (search-imap-connections
-          (let ((url (imap-connection-url connection)))
-            (lambda (connection*)
-              (and (not (eq? connection* connection))
-                   (compatible-imap-urls? (imap-connection-url connection*)
-                                          url)
-                   0))))
+      (if (or no-defer?
+             (search-imap-connections
+              (let ((url (imap-connection-url connection)))
+                (lambda (connection*)
+                  (and (not (eq? connection* connection))
+                       (compatible-imap-urls?
+                        (imap-connection-url connection*)
+                        url)
+                       0)))))
          (close-imap-connection-cleanly connection)
          (defer-closing-of-connection connection))))
 
     (guarantee-imap-folder-open folder)
     folder))
 
-(define-method %close-resource ((folder <imap-folder>))
+(define-method %close-resource ((folder <imap-folder>) no-defer?)
+  (close-imap-folder folder no-defer?))
+
+(define (close-imap-folder folder no-defer?)
   (let ((connection
         (without-interrupts
          (lambda ()
              connection)))))
     (if connection
        (begin
-         (maybe-close-imap-connection connection 0)
+         (maybe-close-imap-connection connection 0 no-defer?)
          (object-modified! folder 'STATUS)))))
 
 (define-method %get-message ((folder <imap-folder>) index)
 (define-method %open-resource ((url <imap-container-url>))
   (make-imap-container url))
 
-(define-method %close-resource ((container <imap-container>))
-  container
+(define-method %close-resource ((container <imap-container>) no-defer?)
+  container no-defer?
   unspecific)
 
 (define-method save-resource ((container <imap-container>))