3 import Data.Func, Data.Functor, Data.Tuple
7 Start w = doTasks master w
11 = get applicationOptions
12 >>- \eo->traceValue ("Master started on port " +++ toString eo.serverPort)
13 >-| updateSharedInformation [] (remoteShare (sharedStore "bork" 42) {domain="localhost",port=9099})
14 // >-| set 42 (remoteShare (sharedStore "bork" 42) {domain="localhost",port=9099})
15 // >-| asyncTask (ExistingNode "localhost" 9099) (blockWait 5)
16 // >-| asyncTask "localhost" 9090 (blockWait 5)
17 // >-| asyncTask (PrivateNode 9099) (traceValue 5 >-| traceValue 42)
18 // >-| asyncTask "localhost" 9099 (updateInformation [] 5)
19 // >-| sleepSortPar [5,1,3,8]
20 >&^ viewSharedInformation []
23 //asyncTaskChannel :: !String !Int !((sds () (Queue r) w) -> Task a) !((sds () (Queue w) r) -> Task b) -> Task (a, b)
24 //asyncTaskChannel host port remote local
25 // = asyncTask host port (remote shareTo)
28 // shareTo :: (sds () (Queue r) (Queue r))
29 // shareTo = sdsFocus ("to-" +++ host +++ toString port) $ memoryStore "asyncITasks-channels" (Just newQueue)
31 // shareFro :: (sds () (Queue w) (Queue w))
32 // shareFro = sdsFocus ("fro-" +++ host +++ toString port) $ memoryStore "asyncITasks-channels" (Just newQueue)
34 blockWait :: Int -> Task Int
35 blockWait i = accWorld (sleep i)
37 sleep :: !Int !*e -> (!Int, !*e)
42 sleepSortPar :: [Int] -> Task [Int]
43 sleepSortPar numbers = parallel
45 /* asyncTaskSpawn port (blockWait num)
46 >-| */appendTask Embedded (\_->return num) stl
49 & port <- [9092..9099]
50 ] [] @? \tv->case tv of
53 # r = [v\\(_, Value v True)<-ts]
54 = Value r (length r == length numbers)