use new mzscheme primitives
svn: r6109
This commit is contained in:
parent
f7da18826d
commit
9c35fbd7ff
|
@ -174,14 +174,15 @@
|
||||||
|
|
||||||
(define-struct (exn:fail:resource exn:fail) (resource))
|
(define-struct (exn:fail:resource exn:fail) (resource))
|
||||||
|
|
||||||
(define 3m? (eq? '3m (system-type 'gc)))
|
(define memory-accounting? (custodian-memory-accounting-available?))
|
||||||
|
|
||||||
(define (call-with-limits sec mb thunk)
|
(define (call-with-limits sec mb thunk)
|
||||||
(let ([cust (make-custodian)]
|
(let ([cust (make-custodian)]
|
||||||
[ch (make-channel)]
|
[ch (make-channel)]
|
||||||
;; use this to copy parameter changes from the sub-thread
|
;; use this to copy parameter changes from the sub-thread
|
||||||
[p current-preserved-thread-cell-values])
|
[p current-preserved-thread-cell-values])
|
||||||
(when (and mb 3m?) (custodian-limit-memory cust (* mb 1024 1024) cust))
|
(when (and mb memory-accounting?)
|
||||||
|
(custodian-limit-memory cust (* mb 1024 1024) cust))
|
||||||
(let* ([work (parameterize ([current-custodian cust])
|
(let* ([work (parameterize ([current-custodian cust])
|
||||||
(thread (lambda ()
|
(thread (lambda ()
|
||||||
(channel-put ch
|
(channel-put ch
|
||||||
|
@ -457,14 +458,8 @@
|
||||||
(set-out!
|
(set-out!
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(parameterize ([current-custodian orig-cust])
|
(parameterize ([current-custodian orig-cust])
|
||||||
(let ([running? (and (thread? user-thread)
|
(let ([buf (get-output-bytes out #t)])
|
||||||
(thread-running? user-thread))])
|
(if bytes? buf (bytes->string/utf-8 buf #\?))))))
|
||||||
(when running? (thread-suspend user-thread))
|
|
||||||
(let ([buf (subbytes (get-output-bytes out)
|
|
||||||
0 (file-position out))])
|
|
||||||
(file-position out 0)
|
|
||||||
(when running? (thread-resume user-thread))
|
|
||||||
(if bytes? buf (bytes->string/utf-8 buf #\?)))))))
|
|
||||||
out)]
|
out)]
|
||||||
[else (error 'make-evaluator "bad sandox-~a spec: ~e" what out)]))
|
[else (error 'make-evaluator "bad sandox-~a spec: ~e" what out)]))
|
||||||
(parameterize* ; the order in these matters
|
(parameterize* ; the order in these matters
|
||||||
|
|
Loading…
Reference in New Issue
Block a user