Add other future/place primitives to TR base-env
Also fixed the type of `place-dead-evt`.
This commit is contained in:
parent
50711f7a6e
commit
72ef0a9323
|
@ -1219,9 +1219,14 @@
|
||||||
;; Section 11.4 (Futures)
|
;; Section 11.4 (Futures)
|
||||||
[future (-poly (A) ((-> A) . -> . (-future A)))]
|
[future (-poly (A) ((-> A) . -> . (-future A)))]
|
||||||
[touch (-poly (A) ((-future A) . -> . A))]
|
[touch (-poly (A) ((-future A) . -> . A))]
|
||||||
|
[futures-enabled? (-> -Boolean)]
|
||||||
|
[current-future (-> (-opt (-future Univ)))]
|
||||||
|
[future? (make-pred-ty (-future Univ))]
|
||||||
|
[would-be-future (-poly (A) ((-> A) . -> . (-future A)))]
|
||||||
[processor-count (-> -PosInt)]
|
[processor-count (-> -PosInt)]
|
||||||
|
|
||||||
;; Section 11.5 (Places)
|
;; Section 11.5 (Places)
|
||||||
|
[place-enabled? (-> -Boolean)]
|
||||||
[place? (make-pred-ty -Place)]
|
[place? (make-pred-ty -Place)]
|
||||||
[place-channel? (make-pred-ty -Place-Channel)]
|
[place-channel? (make-pred-ty -Place-Channel)]
|
||||||
;; FIXME: the `#:at` keyword is for remote places, not supported yet
|
;; FIXME: the `#:at` keyword is for remote places, not supported yet
|
||||||
|
@ -1229,14 +1234,23 @@
|
||||||
#:at (-val #f) #f
|
#:at (-val #f) #f
|
||||||
#:named (Un (-val #f) -Symbol) #f
|
#:named (Un (-val #f) -Symbol) #f
|
||||||
-Place)]
|
-Place)]
|
||||||
|
[dynamic-place* (->key -Module-Path Sym
|
||||||
|
#:in (-opt -Input-Port) #f
|
||||||
|
#:out (-opt -Output-Port) #f
|
||||||
|
#:err (-opt -Output-Port) #f
|
||||||
|
(-values (list -Place
|
||||||
|
(-opt -Output-Port)
|
||||||
|
(-opt -Input-Port)
|
||||||
|
(-opt -Input-Port))))]
|
||||||
[place-wait (-> -Place -Int)]
|
[place-wait (-> -Place -Int)]
|
||||||
[place-dead-evt (-> -Place (make-Evt -Byte))]
|
[place-dead-evt (-> -Place (-mu x (make-Evt x)))]
|
||||||
[place-break (-> -Place -Void)]
|
[place-break (->opt -Place [(-opt (one-of/c 'hang-up 'terminate))] -Void)]
|
||||||
[place-kill (-> -Place -Void)]
|
[place-kill (-> -Place -Void)]
|
||||||
[place-channel (-> (-values (list -Place-Channel -Place-Channel)))]
|
[place-channel (-> (-values (list -Place-Channel -Place-Channel)))]
|
||||||
[place-channel-put (-> -Place-Channel Univ -Void)]
|
[place-channel-put (-> -Place-Channel Univ -Void)]
|
||||||
[place-channel-get (-> -Place-Channel Univ)]
|
[place-channel-get (-> -Place-Channel Univ)]
|
||||||
[place-channel-put/get (-> -Place-Channel Univ Univ)]
|
[place-channel-put/get (-> -Place-Channel Univ Univ)]
|
||||||
|
[place-message-allowed? (-> Univ -Boolean)]
|
||||||
|
|
||||||
;; Section 12 (Macros)
|
;; Section 12 (Macros)
|
||||||
|
|
||||||
|
|
|
@ -149,9 +149,11 @@
|
||||||
racket/fixnum
|
racket/fixnum
|
||||||
racket/flonum
|
racket/flonum
|
||||||
racket/function
|
racket/function
|
||||||
|
racket/future
|
||||||
racket/list
|
racket/list
|
||||||
racket/math
|
racket/math
|
||||||
racket/path
|
racket/path
|
||||||
|
racket/place
|
||||||
racket/port
|
racket/port
|
||||||
racket/sequence
|
racket/sequence
|
||||||
racket/set
|
racket/set
|
||||||
|
@ -1928,6 +1930,37 @@
|
||||||
(call-with-values (lambda () (eval #'(+ 1 2))) (inst list Any))
|
(call-with-values (lambda () (eval #'(+ 1 2))) (inst list Any))
|
||||||
(-lst Univ)]
|
(-lst Univ)]
|
||||||
|
|
||||||
|
;; futures & places primitives
|
||||||
|
[tc-e (future (λ () "foo")) (-future -String)]
|
||||||
|
[tc-e (would-be-future (λ () "foo")) (-future -String)]
|
||||||
|
[tc-e (touch (future (λ () "foo"))) -String]
|
||||||
|
[tc-e (current-future) (-opt (-future Univ))]
|
||||||
|
[tc-e (add1 (processor-count)) -PosInt]
|
||||||
|
[tc-e (assert (current-future) future?) (-future Univ)]
|
||||||
|
[tc-e (futures-enabled?) -Boolean]
|
||||||
|
[tc-e (place-enabled?) -Boolean]
|
||||||
|
[tc-e (dynamic-place "a.rkt" 'a #:at #f) -Place]
|
||||||
|
[tc-e (let-values
|
||||||
|
([(p _1 _2 _3)
|
||||||
|
(dynamic-place* "a.rkt" 'a #:in (open-input-string "hi"))])
|
||||||
|
p)
|
||||||
|
-Place]
|
||||||
|
[tc-e (let ([p (dynamic-place "a.rkt" 'a)])
|
||||||
|
(place-break p)
|
||||||
|
(place-break p 'terminate)
|
||||||
|
(place-kill p)
|
||||||
|
(list (place-wait p)
|
||||||
|
(place-dead-evt p)))
|
||||||
|
(-lst* -Int (-mu x (make-Evt x)))]
|
||||||
|
[tc-e (let ()
|
||||||
|
(define-values (c1 c2) (place-channel))
|
||||||
|
(place-channel-get c2)
|
||||||
|
(place-channel-get c2)
|
||||||
|
(place-channel-put/get c2 "b")
|
||||||
|
(place-channel-put c1 "a"))
|
||||||
|
-Void]
|
||||||
|
[tc-e (place-message-allowed? 'msg) -Boolean]
|
||||||
|
|
||||||
;; for/hash, for*/hash - PR 14306
|
;; for/hash, for*/hash - PR 14306
|
||||||
[tc-e (for/hash: : (HashTable Symbol String)
|
[tc-e (for/hash: : (HashTable Symbol String)
|
||||||
([x (in-list '(x y z))]
|
([x (in-list '(x y z))]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user