thread: fix futures in a non-main place

This commit is contained in:
Matthew Flatt 2018-10-17 06:08:03 -06:00
parent 65e464e626
commit eb6705be3c
2 changed files with 9 additions and 2 deletions

View File

@ -10,7 +10,8 @@
"thread.rkt"
"lock.rkt")
(provide futures-enabled?
(provide init-future-place!
futures-enabled?
current-future
future
future?
@ -27,12 +28,17 @@
reset-future-logs-for-tracing!
mark-future-trace-end!)
(define place-main-thread-id (make-pthread-parameter 0))
(define (init-future-place!)
(place-main-thread-id (get-pthread-id)))
;; not sure of order here...
(define (get-caller)
(cond
[(current-future)
(current-future)]
[(not (= 0 (get-pthread-id)))
[(not (= (place-main-thread-id) (get-pthread-id)))
(get-pthread-id)]
[else
(current-thread)]))

View File

@ -38,6 +38,7 @@
(make-another-initial-thread-group)
(set-root-custodian! c)
(init-system-idle-evt!)
(init-future-place!)
(call-in-main-thread thunk))
;; ----------------------------------------