git.iko.soy/distributed-process
on master help sign in
Cleanup
commit440f2bd3d381dbbdc946fc41fba1d79d9b178431 authorEdsko de Vries <edsko@edsko.net> dateMon 18 Jun 2012, 16:42 (14 years ago) parentab70aa5
4 files changed+16−8
distributed-process/src/Control/Distributed/Process.hs+2 distributed-process/src/Control/Distributed/Process/Closure.hs+7−6 distributed-process/src/Control/Distributed/Process/Internal.hs+6 distributed-process/tests/TestClosure.hs+1−2
distributed-process/src/Control/Distributed/Process.hs+2
@@ -64,6 +64,7 @@ module Control.Distributed.Process
6464 , send
6565 , getSelfPid
6666 , RemoteCallMetaData
67+ , initRemoteCallMetaData
6768 -- * Monitoring and linking
6869 , link
6970 , unlink
@@ -140,6 +141,7 @@ import Data.Accessor ((^.), (^=), (^:))
140141import System.Random (randomIO)
141142import Control.Distributed.Process.Internal.NodeController (runNodeController)
142143import Control.Distributed.Process.Internal ( RemoteCallMetaData
144+ , initRemoteCallMetaData
143145 , NodeId(..)
144146 , LocalProcessId(..)
145147 , ProcessId(..)
distributed-process/src/Control/Distributed/Process/Closure.hs+7−6
@@ -20,21 +20,24 @@
2020--
2121-- > unClosure :: Typeable a => Closure a -> Process a
2222--
23+-- In general, given a monomorphic function @f : a -> b@ the corresponding
24+-- function @$(mkClosure 'f)@ will have type @a -> Closure b@.
25+--
2326-- The call to 'remotable' will also generate a function
2427--
2528-- > __remoteCallMetaData :: RemoteCallMetaData -> RemoteCallMetaData
2629--
2730-- which can be used to construct the 'RemoteCallMetaData' used to initialize
28−-- Cloud Haskell. You should have one call to 'remotable' per module, and
29−-- compose all created functions when initializing Cloud Haskell:
31+-- Cloud Haskell. You should have (at most) one call to 'remotable' per module,
32+-- and compose all created functions when initializing Cloud Haskell:
3033--
3134-- > let metaData = M1.__remoteCallMetaData
3235-- > . M2.__remoteCallMetaData
3336-- > . ...
3437-- > . Mn.__remoteCallMetaData
35−-- > $ Map.empty
38+-- > $ initRemoteCallMetaData
3639--
37−-- See Section 6, Faking It, of Towards Haskell in the Cloud for more info.
40+-- See Section 6, /Faking It/, of /Towards Haskell in the Cloud/ for more info.
3841{-# LANGUAGE TemplateHaskell #-}
3942module Control.Distributed.Process.Closure
4043 ( unClosure
@@ -53,7 +56,6 @@ import Control.Monad.Reader (ask)
5356import Control.Exception (throw)
5457import Language.Haskell.TH ( -- Q monad and operations
5558 Q
56− , report
5759 , reify
5860 -- Names
5961 , Name
@@ -102,7 +104,6 @@ remotable :: [Name] -> Q [Dec]
102104remotable ns = do
103105 (closures, decoders, inserts) <- unzip3 <$> mapM process ns
104106 metaData <- createMetaData inserts
105− report False "Cloud Haskell '__remoteCallMetaData' generated"
106107 return $ concat closures ++ concat decoders ++ metaData
107108
108109-- | Deserialize a closure
distributed-process/src/Control/Distributed/Process/Internal.hs+6
@@ -1,6 +1,7 @@
11module Control.Distributed.Process.Internal
22 ( -- * Global CH state
33 RemoteCallMetaData
4+ , initRemoteCallMetaData
45 , -- * Node and process identifiers
56 NodeId(..)
67 , LocalProcessId(..)
@@ -45,6 +46,7 @@ import Control.Concurrent.Chan (Chan)
4546import Control.Category ((>>>))
4647import Control.Exception (Exception)
4748import Data.Map (Map)
49+import qualified Data.Map as Map (empty)
4850import Data.Int (Int32)
4951import Data.Typeable (Typeable)
5052import Data.Dynamic (Dynamic)
@@ -97,6 +99,10 @@ instance Show ProcessId where
9799-- | Used to fake 'static' (see paper)
98100type RemoteCallMetaData = Map String Dynamic
99101
102+-- | Initial (empty) remote-call meta data
103+initRemoteCallMetaData :: RemoteCallMetaData
104+initRemoteCallMetaData = Map.empty
105+
100106-- | Local nodes
101107data LocalNode = LocalNode
102108 { localNodeId :: NodeId
distributed-process/tests/TestClosure.hs+1−2
@@ -1,6 +1,5 @@
11module Main where
22
3−import qualified Data.Map as Map (empty)
43import Control.Monad.IO.Class (liftIO)
54import Control.Concurrent (forkIO)
65import Control.Concurrent.MVar (MVar, newEmptyMVar, readMVar, takeMVar, putMVar)
@@ -93,7 +92,7 @@ testSendProcClosure transport metaData = do
9392main :: IO ()
9493main = do
9594 Right transport <- createTransport "127.0.0.1" "8080" defaultTCPParameters
96− let metaData = __remoteCallMetaData Map.empty
95+ let metaData = __remoteCallMetaData initRemoteCallMetaData
9796 runTests
9897 [ ("SendPureClosure", testSendPureClosure transport metaData)
9998 , ("SendIOClosure", testSendIOClosure transport metaData)