From ce39dddf04b0880bf395dbf5bea868220bef1a5b Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Fri, 17 Jun 2011 17:01:23 -0400 Subject: [PATCH] Added types for thread operations. Added Custodian type. original commit: bdf0d13970dcb088aa4f71497e3a074b9e26d0b6 --- collects/typed-scheme/base-env/base-env.rkt | 24 ++++++++++++++++++++- collects/typed-scheme/types/abbrev.rkt | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/collects/typed-scheme/base-env/base-env.rkt b/collects/typed-scheme/base-env/base-env.rkt index 3f21fe1c..1f9f8469 100644 --- a/collects/typed-scheme/base-env/base-env.rkt +++ b/collects/typed-scheme/base-env/base-env.rkt @@ -411,22 +411,44 @@ [void (->* '() Univ -Void)] [void? (make-pred-ty -Void)] +;Section 10.1 + +;Section 10.1.1 [thread (-> (-> Univ) -Thread)] [thread? (make-pred-ty -Thread)] [current-thread (-> -Thread)] [thread/suspend-to-kill (-> (-> Univ) -Thread)] +[call-in-nested-thread (-poly (a) (->opt (-> a) [-Custodian] a))] + +;Section 10.1.2 [thread-suspend (-Thread . -> . -Void)] +[thread-resume (->opt -Thread [(Un (-val #f) -Thread -Custodian)] -Void)] [kill-thread (-Thread . -> . -Void)] [break-thread (-Thread . -> . -Void)] [sleep ([N] . ->opt . -Void)] [thread-running? (-Thread . -> . B)] [thread-dead? (-Thread . -> . B)] + +;Section 10.1.3 [thread-wait (-Thread . -> . -Void)] -[thread-send (-poly (a) (-Thread Univ [(-> a)] . ->opt . (Un -Void (-val #f) a)))] + +;TODO need event types +;thread-dead-evt +;thread-resume-evt +;thread-suspend-evt + +;Section 10.1.4 +[thread-send (-poly (a) + (cl->* + (-> -Thread Univ -Void) + (-> -Thread Univ (-val #f) (-opt -Void)) + (-> -Thread Univ (-> a) (Un -Void a))))] [thread-receive (-> Univ)] [thread-try-receive (-> Univ)] [thread-rewind-receive (-> (-lst Univ) -Void)] + + [future (-poly (A) ((-> A) . -> . (-future A)))] [touch (-poly (A) ((-future A) . -> . A))] diff --git a/collects/typed-scheme/types/abbrev.rkt b/collects/typed-scheme/types/abbrev.rkt index 6ee25737..1f8038be 100644 --- a/collects/typed-scheme/types/abbrev.rkt +++ b/collects/typed-scheme/types/abbrev.rkt @@ -206,6 +206,8 @@ (define -Special-Comment (make-Base 'Special-Comment #'special-comment? special-comment? #'-Special-Comment)) +(define -Custodian (make-Base 'Custodian #'custodian? custodian? #'Custodian)) +