cs: fix touch on a future blocked on a fsemaphore

Relevant to #2957
This commit is contained in:
Matthew Flatt 2019-12-09 06:24:11 -07:00
parent 8e884089a2
commit 6db1bdda1b
3 changed files with 20 additions and 2 deletions

View File

@ -0,0 +1,18 @@
#lang racket
;; Check `touch` on a future blocked on an fsemaphore
(define mutex (make-fsemaphore 1))
(define futures
(for/list ([i 10])
(future
(lambda ()
(fsemaphore-wait mutex)
(println (add1 i))
(fsemaphore-post mutex)))))
(void
(map sync
(for/list ([f (in-list futures)])
(thread (lambda () (touch f))))))

View File

@ -17,7 +17,7 @@
[prev #:mutable] ; queue previous
[next #:mutable] ; queue next
[results #:mutable]
[state #:mutable] ; #f (could run), 'running, 'blocked, 'done, 'aborted, 'fsema, or future waiting on
[state #:mutable] ; #f (could run), 'running, 'blocked, 'done, 'aborted, 'fsema or box, or future waiting on
[dependents #:mutable]) ; futures that are blocked on this one
#:authentic
#:reflection-name 'future)

View File

@ -287,7 +287,7 @@
(lock-release (future*-lock f))
(touch s)
(touch f)])]
[(box? s) ; => dependent on fsemaphore
[(or (box? s) (eq? s 'fsema)) ; => dependent on fsemaphore
(cond
[(current-future)
;; Lots to wait on, so give up on the current future for now