minor improvements
svn: r12789
This commit is contained in:
parent
c76a23ed29
commit
3fcc58c05e
|
@ -223,7 +223,7 @@
|
|||
|
||||
;; similar to `call-in-nested-thread', but propagates killing the thread,
|
||||
;; shutting down the custodian or setting parameters and thread cells;
|
||||
;; optionally with thunks to call for kill/shutdown.
|
||||
;; optionally with thunks to call for kill/shutdown instead.
|
||||
(define (call-in-nested-thread*
|
||||
thunk
|
||||
[kill (lambda () (kill-thread (current-thread)))]
|
||||
|
@ -270,8 +270,12 @@
|
|||
(thread (lambda () (sleep sec) (set! r 'time) (kill-thread t)))))
|
||||
(set! r (with-handlers ([void (lambda (e) (list raise e))])
|
||||
(call-with-values thunk (lambda vs (list* values vs))))))
|
||||
(lambda () (unless r (set! r 'kill)))
|
||||
(lambda () (unless r (set! r 'shut)))))
|
||||
(lambda ()
|
||||
(unless r (set! r 'kill))
|
||||
(kill-thread (current-thread)))
|
||||
(lambda ()
|
||||
(unless r (set! r 'shut))
|
||||
(custodian-shutdown-all (current-custodian)))))
|
||||
(unless (custodian-box-value cust-box)
|
||||
(if (memq r '(kill shut)) ; should always be 'shut
|
||||
(set! r 'memory)
|
||||
|
|
|
@ -7,8 +7,14 @@
|
|||
|
||||
;; test call-in-nested-thread*
|
||||
(let ()
|
||||
(define (kill) (kill-thread (current-thread)))
|
||||
(define (shut) (custodian-shutdown-all (current-custodian)))
|
||||
(define-syntax-rule (nested body ...)
|
||||
(call-in-nested-thread* (lambda () body ...)))
|
||||
(define-syntax-rule (nested* body ...)
|
||||
(call-in-nested-thread* (lambda () body ...)
|
||||
(lambda () 'kill)
|
||||
(lambda () 'shut)))
|
||||
(test 1 values (nested 1))
|
||||
;; propagates parameters
|
||||
(let ([p (make-parameter #f)])
|
||||
|
@ -19,13 +25,15 @@
|
|||
;; propagates kill-thread
|
||||
(test (void) thread-wait
|
||||
(thread (lambda ()
|
||||
(nested (kill-thread (current-thread)))
|
||||
(nested (kill))
|
||||
;; never reach here
|
||||
(semaphore-wait (make-semaphore 0)))))
|
||||
;; propagates custodian-shutdown-all
|
||||
(test (void) values
|
||||
(parameterize ([current-custodian (make-custodian)])
|
||||
(nested (custodian-shutdown-all (current-custodian))))))
|
||||
(parameterize ([current-custodian (make-custodian)]) (nested (shut))))
|
||||
;; test handlers parameters
|
||||
(test 'kill (lambda () (nested* (kill))))
|
||||
(test 'shut (lambda () (nested* (shut)))))
|
||||
|
||||
(let ([ev void])
|
||||
(define (run thunk)
|
||||
|
|
Loading…
Reference in New Issue
Block a user