shorten some lines
This commit is contained in:
parent
c7700dbe06
commit
3ec54a61c2
|
@ -93,15 +93,13 @@
|
||||||
(send/msg cmd-list in))])
|
(send/msg cmd-list in))])
|
||||||
(loop idle (cons (list job wrkr) inflight) count error-count)))]
|
(loop idle (cons (list job wrkr) inflight) count error-count)))]
|
||||||
;; Queue empty and all workers idle, we are all done
|
;; Queue empty and all workers idle, we are all done
|
||||||
[(list (and (? empty?) idle) (list) count error-count)
|
[(list (and (? empty?) idle) (list) count error-count) (set! workers idle)]
|
||||||
(set! workers idle)]
|
|
||||||
;; Wait for reply from worker
|
;; Wait for reply from worker
|
||||||
[(list idle inflight count error-count)
|
[(list idle inflight count error-count)
|
||||||
(apply sync (map (λ (node-worker) (match node-worker
|
(apply sync (map (λ (node-worker) (match node-worker
|
||||||
[(list node (and wrkr (worker id sh out in err)))
|
[(list node (and wrkr (worker id sh out in err)))
|
||||||
(handle-evt out (λ (e)
|
(handle-evt out (λ (e)
|
||||||
(let ([msg
|
(let ([msg (with-handlers* ([exn:fail? (lambda (e)
|
||||||
(with-handlers* ([exn:fail? (lambda (e)
|
|
||||||
(printf "MASTER READ ERROR - reading from worker: ~a\n" (exn-message e))
|
(printf "MASTER READ ERROR - reading from worker: ~a\n" (exn-message e))
|
||||||
(kill-worker wrkr)
|
(kill-worker wrkr)
|
||||||
(loop (cons (spawn id) idle)
|
(loop (cons (spawn id) idle)
|
||||||
|
@ -110,8 +108,7 @@
|
||||||
(add1 error-count)))])
|
(add1 error-count)))])
|
||||||
(read out))])
|
(read out))])
|
||||||
(work-done jobqueue node id msg)
|
(work-done jobqueue node id msg)
|
||||||
(loop
|
(loop (cons wrkr idle)
|
||||||
(cons wrkr idle)
|
|
||||||
(remove node-worker inflight)
|
(remove node-worker inflight)
|
||||||
(add1 count)
|
(add1 count)
|
||||||
error-count))))]))
|
error-count))))]))
|
||||||
|
@ -119,9 +116,7 @@
|
||||||
inflight))])])
|
inflight))])])
|
||||||
(loop workers null 0 0)))
|
(loop workers null 0 0)))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(for ([p workers])
|
(for ([p workers]) (with-handlers ([exn? void]) (send/msg (list 'DIE) (worker-in p))))
|
||||||
(with-handlers ([exn? void])
|
|
||||||
(send/msg (list 'DIE) (worker-in p))))
|
|
||||||
(for ([p workers]) (subprocess-wait (worker-process-handle p))))))
|
(for ([p workers]) (subprocess-wait (worker-process-handle p))))))
|
||||||
|
|
||||||
(define (parallel-do-default-error-handler work error-message outstr errstr)
|
(define (parallel-do-default-error-handler work error-message outstr errstr)
|
||||||
|
@ -129,9 +124,8 @@
|
||||||
(printf "STDOUT\n~a=====\n" outstr)
|
(printf "STDOUT\n~a=====\n" outstr)
|
||||||
(printf "STDERR\n~a=====\n" errstr))
|
(printf "STDERR\n~a=====\n" errstr))
|
||||||
|
|
||||||
(define-struct list-queue (queue results create-job-thunk success-thunk failure-thunk) #:transparent
|
(define-struct list-queue (queue results create-job-thunk success-thunk failure-thunk)
|
||||||
#:mutable
|
#:transparent #:mutable #:property prop:jobqueue
|
||||||
#:property prop:jobqueue
|
|
||||||
(define-methods jobqueue
|
(define-methods jobqueue
|
||||||
(define (work-done jobqueue work workerid msg)
|
(define (work-done jobqueue work workerid msg)
|
||||||
(match msg
|
(match msg
|
||||||
|
|
Loading…
Reference in New Issue
Block a user