Add other future/place primitives to TR base-env

Also fixed the type of `place-dead-evt`.
This commit is contained in:
Asumu Takikawa 2014-02-07 17:20:48 -05:00
parent 50711f7a6e
commit 72ef0a9323
2 changed files with 49 additions and 2 deletions

View File

@ -1219,9 +1219,14 @@
;; Section 11.4 (Futures)
[future (-poly (A) ((-> A) . -> . (-future 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)]
;; Section 11.5 (Places)
[place-enabled? (-> -Boolean)]
[place? (make-pred-ty -Place)]
[place-channel? (make-pred-ty -Place-Channel)]
;; FIXME: the `#:at` keyword is for remote places, not supported yet
@ -1229,14 +1234,23 @@
#:at (-val #f) #f
#:named (Un (-val #f) -Symbol) #f
-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-dead-evt (-> -Place (make-Evt -Byte))]
[place-break (-> -Place -Void)]
[place-dead-evt (-> -Place (-mu x (make-Evt x)))]
[place-break (->opt -Place [(-opt (one-of/c 'hang-up 'terminate))] -Void)]
[place-kill (-> -Place -Void)]
[place-channel (-> (-values (list -Place-Channel -Place-Channel)))]
[place-channel-put (-> -Place-Channel Univ -Void)]
[place-channel-get (-> -Place-Channel Univ)]
[place-channel-put/get (-> -Place-Channel Univ Univ)]
[place-message-allowed? (-> Univ -Boolean)]
;; Section 12 (Macros)

View File

@ -149,9 +149,11 @@
racket/fixnum
racket/flonum
racket/function
racket/future
racket/list
racket/math
racket/path
racket/place
racket/port
racket/sequence
racket/set
@ -1928,6 +1930,37 @@
(call-with-values (lambda () (eval #'(+ 1 2))) (inst list Any))
(-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
[tc-e (for/hash: : (HashTable Symbol String)
([x (in-list '(x y z))]