parent
8e884089a2
commit
6db1bdda1b
18
pkgs/racket-test/tests/future/fsemaphore.rkt
Normal file
18
pkgs/racket-test/tests/future/fsemaphore.rkt
Normal 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))))))
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user