Created
March 26, 2014 21:29
-
-
Save tonyday567/9794019 to your computer and use it in GitHub Desktop.
Revisions
-
tonyday567 created this gist
Mar 26, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ tRemote :: Int -> IO () tRemote n = do backend0 <- initializeBackend host portSlave rtable node0 <- newLocalNode backend0 backend <- initializeBackend host portMaster rtable node <- newLocalNode backend Node.runProcess node (remotePipe' n (Node.localNodeId node0)) where rtable :: RemoteTable rtable = __remoteTable initRemoteTable remotePipe' :: Int -> NodeId -> Process () remotePipe' n nodeid = do (out0, in0) <- newChan -- main remote channel (outPing, inPing) <- newChan -- ping channel spawnLocal' $ do -- spawnLocal makes sure this is a non-blocking call spawnAsync nodeid (remoteDoublerClosure (outPing, out0)) -- another channel inside the closure _ <- expectTimeout 0 :: Process (Maybe DidSpawn) return () output <- receiveChan inPing -- Wait for remote pipe to send back the output channel details spawnLocal' $ runEffect $ each [1..n] >-> toOutput output -- feeding remote with values runEffect $ fromInput in0 >-> P.take n >-> P.print -- receiving values from remote