* rename with-limits -> call-with-limits
* add a with-limits macro svn: r5357
This commit is contained in:
parent
c98b4a15b2
commit
6df2f54ac6
|
@ -673,7 +673,7 @@ by this function.
|
|||
See also `with-limits' below for adding resource limits, and
|
||||
`get-uncovered-expressions' above for enforcing test coverage.
|
||||
|
||||
> (with-limits sec mb thunk)
|
||||
> (call-with-limits sec mb thunk)
|
||||
This function executes the given thunk with memory and time
|
||||
restrictions: if execution consumes more than `mb' megabytes or more
|
||||
that `sec' seconds, then the computation is aborted and an error is
|
||||
|
@ -684,6 +684,9 @@ by this function.
|
|||
(Note: memory limit requires running in a 3m executable; the limit
|
||||
is only checked after a GC happens.)
|
||||
|
||||
> (with-limits sec mb body ...)
|
||||
A macro version of the above.
|
||||
|
||||
|
||||
_utils.ss_
|
||||
----------
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
|
||||
;; Resources ----------------------------------------------------------------
|
||||
|
||||
(define (with-limits sec mb thunk)
|
||||
(define (call-with-limits sec mb thunk)
|
||||
(let ([cust (make-custodian)]
|
||||
[ch (make-channel)])
|
||||
(when mb (custodian-limit-memory cust (* mb 1024 1024) cust))
|
||||
|
@ -219,4 +219,9 @@
|
|||
(apply (car r) (cdr r))
|
||||
(error 'with-limit "out of ~a" r)))))
|
||||
|
||||
(define-syntax with-limits
|
||||
(syntax-rules ()
|
||||
[(with-limits sec mb body ...)
|
||||
(call-with-limits sec mb (lambda () body ...))]))
|
||||
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user