From 0140429ff1785b6ff033813fe4d4c7cdb018e5a9 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 2 Mar 2020 15:17:12 +0100 Subject: [PATCH] . --- cloudiTasks/cloudiTasks.icl | 53 +++++++++++++------------------------ 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/cloudiTasks/cloudiTasks.icl b/cloudiTasks/cloudiTasks.icl index 1cd0d36..2693038 100644 --- a/cloudiTasks/cloudiTasks.icl +++ b/cloudiTasks/cloudiTasks.icl @@ -1,34 +1,22 @@ module cloudiTasks -import Data.Func +import Data.Func, Data.Functor, Data.Tuple import StdEnv import iTasks 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, onStartup o master) - = Ok (s args, {eo & distributed=True}) +Start w = doTasks master w -slave :: [String] -> Task () -slave args - = get applicationOptions - >>- \eo->traceValue ("Slave started on port " +++ toString eo.sdsPort) - >-| asyncTaskListener - -master :: [String] -> Task () -master args +master :: Task () +master = get applicationOptions >>- \eo->traceValue ("Master started on port " +++ toString eo.serverPort) -// >-| asyncTask (PrivateNode 9099 ["--slave", "9099"]) (blockWait 5) -// >-| asyncTask (PrivateNode 9099 ["--slave", "9099"]) (traceValue 5 >-| traceValue 42) // >-| asyncTask (ExistingNode "localhost" 9099) (blockWait 5) - >-| sleepSortPar [1,2,3,4] -// >&> viewSharedInformation [] - >>- traceValue + >-| asyncTask (PrivateNode 9099) (blockWait 5) +// >-| asyncTask (PrivateNode 9099) (traceValue 5 >-| traceValue 42) +// >-| asyncTask (PrivateNode 9099) (updateInformation [] 42) +// >-| sleepSortPar [5,1,3,8] + >&^ viewSharedInformation [] @! () blockWait :: Int -> Task Int @@ -39,21 +27,16 @@ where 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) + [ (Embedded, \stl-> + asyncTask (PrivateNode port) (blockWait num) + >-| appendTask Embedded (\_->return num) stl + @? const NoValue) \\ 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) + ] [] @? \tv->case tv of + NoValue = NoValue + (Value ts _) + # r = [v\\(_, Value v True)<-ts] + = Value r (length r == length numbers) -- 2.20.1