Clarifying
svn: r6622
This commit is contained in:
parent
e433ec1144
commit
2445c88ed8
|
@ -113,12 +113,11 @@ deployments of the @web-server .
|
||||||
|
|
||||||
@file{managers/lru.ss} defines a manager constructor:
|
@file{managers/lru.ss} defines a manager constructor:
|
||||||
|
|
||||||
@; XXX Rename time0 and time1
|
|
||||||
@; XXX Cite Continue
|
@; XXX Cite Continue
|
||||||
@defproc[(create-LRU-manager
|
@defproc[(create-LRU-manager
|
||||||
[instance-expiration-handler expiration-handler?]
|
[instance-expiration-handler expiration-handler?]
|
||||||
[time0 integer?]
|
[check-interval integer?]
|
||||||
[time1 integer?]
|
[collect-interval integer?]
|
||||||
[collect? (-> boolean?)]
|
[collect? (-> boolean?)]
|
||||||
[#:initial-count initial-count integer? 1]
|
[#:initial-count initial-count integer? 1]
|
||||||
[#:inform-p inform-p (integer? . -> . void) (lambda _ (void))])
|
[#:inform-p inform-p (integer? . -> . void) (lambda _ (void))])
|
||||||
|
@ -135,8 +134,8 @@ deployments of the @web-server .
|
||||||
is thrown with @scheme[instance-exp-handler] as the expiration handler, if
|
is thrown with @scheme[instance-exp-handler] as the expiration handler, if
|
||||||
no expiration-handler was passed to @scheme[continuation-store!].
|
no expiration-handler was passed to @scheme[continuation-store!].
|
||||||
|
|
||||||
Every @scheme[time0] seconds @scheme[collect?] is called to determine
|
Every @scheme[check-interval] seconds @scheme[collect?] is called to determine
|
||||||
if the collection routine should be run. Every @scheme[time1] seconds
|
if the collection routine should be run. Every @scheme[collect-interval] seconds
|
||||||
the collection routine is run.
|
the collection routine is run.
|
||||||
|
|
||||||
Every time the collection routine runs, the "Life Count" of every
|
Every time the collection routine runs, the "Life Count" of every
|
||||||
|
@ -148,8 +147,8 @@ deployments of the @web-server .
|
||||||
|
|
||||||
The recommended use of this manager is to pass, as @scheme[collect?], a
|
The recommended use of this manager is to pass, as @scheme[collect?], a
|
||||||
function that checks the memory usage of the system, through
|
function that checks the memory usage of the system, through
|
||||||
@scheme[current-memory-use]. Then, @scheme[time1] should be sufficiently
|
@scheme[current-memory-use]. Then, @scheme[collect-interval] should be sufficiently
|
||||||
large compared to @scheme[time0]. This way, if the load on the server
|
large compared to @scheme[check-interval]. This way, if the load on the server
|
||||||
spikes---as indicated by memory usage---the server will quickly expire
|
spikes---as indicated by memory usage---the server will quickly expire
|
||||||
continuations, until the memory is back under control. If the load
|
continuations, until the memory is back under control. If the load
|
||||||
stays low, it will still efficiently expire old continuations.
|
stays low, it will still efficiently expire old continuations.
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
next-instance-id))
|
next-instance-id))
|
||||||
(define/kw (create-LRU-manager
|
(define/kw (create-LRU-manager
|
||||||
instance-expiration-handler
|
instance-expiration-handler
|
||||||
time0 time1
|
check-interval collect-interval
|
||||||
collect?
|
collect?
|
||||||
#:key
|
#:key
|
||||||
[initial-count 1]
|
[initial-count 1]
|
||||||
|
@ -154,18 +154,18 @@
|
||||||
(define (seconds->msecs s)
|
(define (seconds->msecs s)
|
||||||
(+ (current-inexact-milliseconds)
|
(+ (current-inexact-milliseconds)
|
||||||
(* s 1000)))
|
(* s 1000)))
|
||||||
(let loop ([msecs0 (seconds->msecs time0)]
|
(let loop ([msecs0 (seconds->msecs check-interval)]
|
||||||
[msecs1 (seconds->msecs time1)])
|
[msecs1 (seconds->msecs collect-interval)])
|
||||||
(sync (handle-evt
|
(sync (handle-evt
|
||||||
(alarm-evt msecs0)
|
(alarm-evt msecs0)
|
||||||
(lambda _
|
(lambda _
|
||||||
(when (collect?)
|
(when (collect?)
|
||||||
(collect #f))
|
(collect #f))
|
||||||
(loop (seconds->msecs time0) msecs1)))
|
(loop (seconds->msecs check-interval) msecs1)))
|
||||||
(handle-evt
|
(handle-evt
|
||||||
(alarm-evt msecs1)
|
(alarm-evt msecs1)
|
||||||
(lambda _
|
(lambda _
|
||||||
(collect #t)
|
(collect #t)
|
||||||
(loop msecs0 (seconds->msecs time1)))))))))
|
(loop msecs0 (seconds->msecs collect-interval)))))))))
|
||||||
|
|
||||||
the-manager))
|
the-manager))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user