Add `get-user-custodian' to the sandbox.

This commit is contained in:
Eli Barzilay 2010-11-16 14:36:04 -05:00
parent 82437faa18
commit afa8e6c86b
2 changed files with 16 additions and 0 deletions

View File

@ -32,6 +32,7 @@
evaluator-alive?
kill-evaluator
break-evaluator
get-user-custodian
set-eval-limits
set-eval-handler
put-input
@ -621,6 +622,7 @@
(define-evaluator-messenger evaluator-alive? 'alive?)
(define-evaluator-messenger kill-evaluator 'kill)
(define-evaluator-messenger break-evaluator 'break)
(define-evaluator-messenger get-user-custodian 'user-cust)
(define-evaluator-messenger (set-eval-limits secs mb) 'limits)
(define-evaluator-messenger (set-eval-handler handler) 'handler)
(define-evaluator-messenger (put-input . xs) 'input)
@ -819,6 +821,7 @@
[(alive?) (and user-thread (not (thread-dead? user-thread)))]
[(kill) (terminate+kill! 'evaluator-killed #f)]
[(break) (user-break)]
[(user-cust) user-cust]
[(limits) (set! limits (evaluator-message-args expr))]
[(handler) (set! eval-handler (car (evaluator-message-args expr)))]
[(input) (apply input-putter (evaluator-message-args expr))]

View File

@ -730,6 +730,19 @@ Ctrl-C was typed when the evaluator is currently executing, which
propagates the break to the evaluator's context.}
@defproc[(get-user-custodian [evaluator (any/c . -> . any)]) void?]{
Retrieves the @racket[evaluator]'s toplevel custodian. This returns a
value that is different from @racket[(evaluator '(current-custodian))]
or @racket[call-in-sandbox-context evaluator current-custodian] --- each
sandbox interaction is wrapped in its own custodian, which is what these
would return.
(One use for this custodian is with @racket[current-memory-use], where
the per-interaction sub-custodians will not be charged with the memory
for the whole sandbox.)}
@defproc[(set-eval-limits [evaluator (any/c . -> . any)]
[secs (or/c exact-nonnegative-integer? #f)]
[mb (or/c exact-nonnegative-integer? #f)])