mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-24 12:14:26 +03:00
Implement Racket Futures Support
This commit is contained in:
parent
4f05d227a6
commit
d712ea288a
@ -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)))
|
||||
|
||||
|
@ -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
|
||||
|
23
tests/racket/concurrency001/Futures.idr
Normal file
23
tests/racket/concurrency001/Futures.idr
Normal 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)
|
4
tests/racket/concurrency001/expected
Normal file
4
tests/racket/concurrency001/expected
Normal file
@ -0,0 +1,4 @@
|
||||
String
|
||||
#1
|
||||
#2
|
||||
#3
|
4
tests/racket/concurrency001/run
Normal file
4
tests/racket/concurrency001/run
Normal 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
|
Loading…
Reference in New Issue
Block a user