Implement Racket Futures Support

This commit is contained in:
Fabián Heredia Montiel 2021-01-13 14:54:43 -06:00 committed by G. Allais
parent 4f05d227a6
commit d712ea288a
5 changed files with 39 additions and 0 deletions

View File

@ -211,6 +211,9 @@
(define (blodwen-condition-signal c)
(channel-put c 'ready))
(define (blodwen-make-future work) (future work))
(define (blodwen-await-future ty future) (touch future))
(define (blodwen-sleep s) (sleep s))
(define (blodwen-usleep us) (sleep (* 0.000001 us)))

View File

@ -145,6 +145,10 @@ chezTests = MkTestPool [Chez]
"perf001",
"reg001"]
racketTests : TestPool
racketTests = MkTestPool [Racket]
["concurrency001"]
nodeTests : TestPool
nodeTests = MkTestPool [Node]
[ "node001", "node002", "node003", "node004", "node005", "node006", "node007", "node008", "node009"
@ -176,6 +180,7 @@ main = runner
, testPaths "ideMode" ideModeTests
, testPaths "prelude" preludeTests
, testPaths "chez" chezTests
, testPaths "racket" racketTests
, testPaths "node" nodeTests
, testPaths "templates" templateTests
] where

View File

@ -0,0 +1,23 @@
module Futures
import Data.List
import Data.So
import System
import System.Future
import System.Info
constant : IO ()
constant = do
let a = await $ fork "String"
putStrLn a
map : IO ()
map = do
future1 <- forkIO $ do
usleep 10000
putStrLn "#2"
let future3 = map (const "#3") future1
future2 <- forkIO $ do
putStrLn "#1"
pure $ await future2
putStrLn (await future3)

View File

@ -0,0 +1,4 @@
String
#1
#2
#3

View File

@ -0,0 +1,4 @@
$1 --no-banner --no-color --console-width 0 --cg racket Futures.idr -p contrib --exec constant
$1 --no-banner --no-color --console-width 0 --cg racket Futures.idr -p contrib --exec map
rm -r build