> 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 (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 > halt > ) "LELoop" > loop :: Pid -> Int -> DIO Msg () > loop _ 0 = return () > loop pid (i+1) = do > remoteSend (Hostname "localhost") (Nodename "LELoop") "Reader" Ping > proc $ putStr "." > receive (\v -> case v of > Pong -> return () > ) > loop pid i > reader :: Pid -> DIO Msg () > reader parent = do > receive (\v -> case v of > Ping -> do > proc $ putStr "#" > parent Pong > reader parent > Quit -> do > return () > )