From 9343419d1659f24d616ef9a64292c2896b603163 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 2 Mar 2020 11:09:14 +0100 Subject: [PATCH] .' --- cloudiTasks/cloudiTasks.icl | 32 ++++++++++++++++++++++++++++---- rank2/test.icl | 26 ++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/cloudiTasks/cloudiTasks.icl b/cloudiTasks/cloudiTasks.icl index 081848e..1cd0d36 100644 --- a/cloudiTasks/cloudiTasks.icl +++ b/cloudiTasks/cloudiTasks.icl @@ -1,14 +1,16 @@ module cloudiTasks +import Data.Func import StdEnv import iTasks -import Data.Func +import iTasks.Extensions.DateTime import iTasks.Extensions.Distributed Start w = flip doTasksWithOptions w \args eo # (eo, s) = case args of [argv0,"--slave",p] = ({eo & sdsPort=toInt p}, onStartup o slave) - _ = (eo, onRequest "/" o master) + //_ = (eo, onRequest "/" o master) + _ = (eo, onStartup o master) = Ok (s args, {eo & distributed=True}) slave :: [String] -> Task () @@ -21,9 +23,12 @@ master :: [String] -> Task () master args = get applicationOptions >>- \eo->traceValue ("Master started on port " +++ toString eo.serverPort) - >-| asyncTask (PrivateNode 9099 ["--slave", "9099"]) (blockWait 5) +// >-| asyncTask (PrivateNode 9099 ["--slave", "9099"]) (blockWait 5) +// >-| asyncTask (PrivateNode 9099 ["--slave", "9099"]) (traceValue 5 >-| traceValue 42) // >-| asyncTask (ExistingNode "localhost" 9099) (blockWait 5) - >>! \s->viewInformation [] s + >-| sleepSortPar [1,2,3,4] +// >&> viewSharedInformation [] + >>- traceValue @! () blockWait :: Int -> Task Int @@ -33,3 +38,22 @@ where sleep _ _ = code { ccall sleep "I:I:A" } + +sleepSort :: [Int] -> Task [Int] +sleepSort numbers = parallel + [ (Embedded, \_->waitForTimer False num >-| return num) + \\ num <- numbers + ] [] @? tresult (length numbers) + +sleepSortPar :: [Int] -> Task [Int] +sleepSortPar numbers = parallel + [ (Embedded, \_->asyncTask + (PrivateNode port ["--slave", toString port]) + $ blockWait num >-| return num) + \\ num <- numbers + & port <- [9091..9099] + ] [] @? tresult (length numbers) + +tresult l NoValue = NoValue +tresult l (Value ts _) + = let r = [v\\(_, Value v True)<-ts] in Value r (length r == l) diff --git a/rank2/test.icl b/rank2/test.icl index 81685e2..fb00656 100644 --- a/rank2/test.icl +++ b/rank2/test.icl @@ -25,12 +25,30 @@ instance expr Print where lit i = Print (toString i) +. (Print l) (Print r) = Print (l +++ "+" +++ r) -printEval :: (A.v: v a | expr v) -> (Maybe a, String) -printEval f = (eval f, let (Print p) = f in p) +//printEval :: (A.v: v a | expr v & + (v Int)) -> (Maybe a, String) +//printEval :: (A.v: v a | expr v & + (v Int)) -> (Maybe a, String) +//printEval f = (eval f, print f) + +printEval` :: (v a) (w a) -> (Maybe a, String) | expr v & expr w +printEval` f1 f2 = (eval f1, print f2) + +printEval f :== printEval` f f + +//x = lit 4 + lit 28 +//y = lit 4 +. lit 28 //Mag niet +//Start = printEval (lit 4 +. lit 38) Start :: (Maybe Int, String) -Start = printEval (lit 4 +. lit 38) +//Start = printEval (lit 2 + lit 40) +Start = printEval` expr expr +//Start = printEval expr + +expr :: v Int | expr v & + (v Int) +expr = lit 4 + lit 38 +//Start = printEval (lit 4 +. lit 38) + +//Start = eval (lit 4 + lit 38) //Mag wel -//Start = let (Print f) = lit 4 + lit 38 in f +//Start = print (lit 4 + lit 38) -- 2.20.1