fix busyloop bug in agent
This commit is contained in:
parent
d41d8ee246
commit
0a9902d83e
|
@ -292,7 +292,7 @@
|
||||||
(for/list ([i (in-naturals)] [wr (in-list pattern-ranges)])
|
(for/list ([i (in-naturals)] [wr (in-list pattern-ranges)])
|
||||||
(define b (box #f))
|
(define b (box #f))
|
||||||
(cons (thread (lambda () (execute-cpu-wrap wr b))) b))))
|
(cons (thread (lambda () (execute-cpu-wrap wr b))) b))))
|
||||||
(let loop ()
|
(let loop ([children children])
|
||||||
(with-handlers ([exn? (lambda (ex)
|
(with-handlers ([exn? (lambda (ex)
|
||||||
(log-agent-error "stopping assignment ~a due to error" aid)
|
(log-agent-error "stopping assignment ~a due to error" aid)
|
||||||
;; break all children
|
;; break all children
|
||||||
|
@ -304,12 +304,12 @@
|
||||||
;; reraise
|
;; reraise
|
||||||
(raise ex))])
|
(raise ex))])
|
||||||
(apply sync/enable-break (map car children))
|
(apply sync/enable-break (map car children))
|
||||||
(define threads-running? (ormap (compose thread-running? car) children))
|
(define-values [pending completed] (partition (compose thread-running? car) children))
|
||||||
(define any-exn (ormap (compose unbox cdr) children))
|
(for ([k (in-list completed)])
|
||||||
(when any-exn
|
(let ([maybe-exn (unbox (cdr k))])
|
||||||
(raise any-exn))
|
(when maybe-exn (raise maybe-exn))))
|
||||||
(when threads-running?
|
(unless (empty? pending)
|
||||||
(loop))))
|
(loop pending))))
|
||||||
(break-enabled #t))
|
(break-enabled #t))
|
||||||
|
|
||||||
(cleanup)
|
(cleanup)
|
||||||
|
|
Loading…
Reference in New Issue