> module Main where > import IO > import Distributed > data Msg = Ping | Pong | Quit deriving (Read,Show) > instance Serialize Msg > main = do > hSetBuffering stdout NoBuffering > Distributed.start (do > me <- self > -- we must sync > pid <- spawn (do > register "Reader" > me Ping > reader me > ) > valStr <- proc $ myGetVarDefault "CNT" "1000" > let val = ((read valStr) :: Int) > receive (\v -> case v of > Ping -> return () > ) > loop pid val > pid Quit > receive (\v -> case v of > Quit -> return () > ) > halt > ) "X" > loop :: Pid -> Int -> DIO Msg () > loop _ 0 = return () > loop pid (i+1) = do > remoteSend (Hostname "localhost") (Nodename "X") "Reader" Ping > proc $ putStr "." > loop pid i > reader :: Pid -> DIO Msg () > reader parent = do > proc $ print "z" > receive (\v -> case v of > Ping -> do > proc $ putStr "#" > reader parent > Quit -> do > parent Quit > return () > )