cs & thread: simplificaton for future "sync" action

This commit is contained in:
Matthew Flatt 2019-10-09 15:52:34 -06:00
parent 7cc3345761
commit f3aae7f4fb

View File

@ -369,20 +369,17 @@
[else [else
;; In case the main thread is trying to shut down futures, check in: ;; In case the main thread is trying to shut down futures, check in:
(engine-block) (engine-block)
;; Atomic mode prevents getting terminated or swapped out ;; Host's `call-as-asynchronous-callback` will post `thunk`
;; while we block on the main thread ;; so that it's returned by `host:poll-async-callbacks` to
(current-atomic (add1 (current-atomic))) ;; the scheduler in the place's main thread; it will also
(begin0 ;; tell the scheduler to be in atomic mode so that we don't
;; Host's `call-as-asynchronous-callback` will post `thunk` ;; get terminated or swapped out while blocking on the main thread
;; so that it's returned by `host:poll-async-callbacks` to (host:call-as-asynchronous-callback
;; the scheduler in the place's main thread (lambda ()
(host:call-as-asynchronous-callback (log-future 'sync (future*-id me-f) #:prim-name who)
(lambda () (let ([v (thunk)])
(log-future 'sync (future*-id me-f) #:prim-name who) (log-future 'result (future*-id me-f))
(let ([v (thunk)]) v)))]))
(log-future 'result (future*-id me-f))
v)))
(current-atomic (sub1 (current-atomic))))]))
;; ---------------------------------------- ;; ----------------------------------------