Changeset 17996 in project


Ignore:
Timestamp:
05/04/10 09:50:48 (9 years ago)
Author:
Jim Ursetto
Message:

chicken-doc: Add repository-modification-time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/chicken-doc/trunk/chicken-doc.scm

    r17977 r17996  
    2020 make-id-cache id-cache-filename
    2121 make-repository-placeholder
     22 repository-modification-time
    2223;; Node API
    2324 lookup-node
     
    199200         (read-file file))))
    200201
     202#|
     203(define (node-modification-time node)
     204  ;; hypothetical function returning the last update time of a node.
     205  ;; The most accurate result is probably obtained by returning the
     206  ;; mtime of the ,meta file.  Clients may also want to know when
     207  ;; children have been updated (or at least when the child IDs change).
     208  ;; It may be sufficient to check the parent directory mtime or
     209  ;; the max of that and ,meta since rename, add and delete of child
     210  ;; directories will change parent mtime.  Parent mtime is usually
     211  ;; not affected when ,meta or ,sxml file is overwritten, though.
     212  )
     213 
     214|#
     215
    201216;;; Describe
    202217
     
    297312  (hash-table-keys (id-cache-table c)))
    298313
    299 ;; Validate and update the shared id cache in the current repository.
    300 (define (validate-id-cache!)
     314;; Validate and update the shared id cache in repository R.
     315(define (validate-id-cache! r)
    301316  (define (read-id-cache! r c)
    302317    (define (read-id-cache c)
     
    314329  ;; updated, if two threads validate at the same time both will
    315330  ;; read the entire cache in.
    316   (let* ((r (current-repository))
    317          (c (repository-id-cache r)))
     331  (let* ((c (repository-id-cache r)))
    318332    (when (< (id-cache-mtime c)
    319333             (file-modification-time (id-cache-filename c)))
     
    339353  (define (lookup id)
    340354    (id-cache-ref (current-id-cache) id))
    341   (validate-id-cache!)
     355  (validate-id-cache! (current-repository))
    342356  (let ((id (if (string? id) (string->symbol id) id)))
    343357    (map (lambda (x)
     
    349363(define (match-nodes/re re)
    350364  (let ((rx (irregex re)))
    351     (validate-id-cache!)
     365    (validate-id-cache! (current-repository))
    352366    (append-map (lambda (id)
    353367                  (match-nodes id))
     
    359373(define (match-node-paths/re re)
    360374  (let ((rx (irregex re)))
    361     (validate-id-cache!)
     375    (validate-id-cache! (current-repository))
    362376    (map (lambda (path)
    363377           (lookup-node (string-split path))) ; stupid resplit
     
    501515  (void))
    502516
     517;; Last modification time of entire repository.  We just use the mtime
     518;; of the id cache, as update operations do not modify any global timestamp.
     519;; This means stale data may be returned until the cache is refreshed.
     520(define (repository-modification-time r)
     521  (validate-id-cache! r)  ;; may be wasteful, but we need the current mtime
     522  (id-cache-mtime (repository-id-cache r)))
     523
    503524;;; REPL
    504525
Note: See TracChangeset for help on using the changeset viewer.