* rename with-limits -> call-with-limits

* add a with-limits macro

svn: r5357
This commit is contained in:
Eli Barzilay 2007-01-16 02:28:48 +00:00
parent c98b4a15b2
commit 6df2f54ac6
2 changed files with 10 additions and 2 deletions

View File

@ -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_
----------

View File

@ -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 ...))]))
)