mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
memoization: Add 'invalidate-memoization!.
* guix/memoization.scm (%make-hash-table*): When not profiling, add the new table to %MEMOIZATION-TABLES. (invalidate-memoization!): New procedure.
This commit is contained in:
parent
90354e34e3
commit
d1f01e4845
1 changed files with 13 additions and 2 deletions
|
@ -21,7 +21,8 @@ (define-module (guix memoization)
|
|||
#:use-module (ice-9 match)
|
||||
#:autoload (srfi srfi-1) (count)
|
||||
#:use-module (srfi srfi-9)
|
||||
#:export (memoize
|
||||
#:export (invalidate-memoization!
|
||||
memoize
|
||||
mlambda
|
||||
mlambdaq))
|
||||
|
||||
|
@ -113,11 +114,21 @@ (define %make-hash-table*
|
|||
(cons cache location))
|
||||
cache))
|
||||
(lambda (proc location)
|
||||
(make-hash-table))))
|
||||
(let ((table (make-hash-table)))
|
||||
(hashq-set! %memoization-tables proc table)
|
||||
table))))
|
||||
|
||||
(define-syntax-rule (make-hash-table* proc)
|
||||
(%make-hash-table* proc (current-source-location)))
|
||||
|
||||
(define (invalidate-memoization! proc)
|
||||
"Invalidate the memoization cache of PROC."
|
||||
(match (hashq-ref %memoization-tables proc)
|
||||
((? hash-table? table)
|
||||
(hash-clear! table))
|
||||
(((? cache? cache) . _)
|
||||
(hash-clear! (cache-table cache)))))
|
||||
|
||||
(define* (show-memoization-tables #:optional (port (current-error-port)))
|
||||
"Display to PORT statistics about the memoization tables."
|
||||
(define (cache<? p1 p2)
|
||||
|
|
Loading…
Reference in a new issue