-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Cloud Haskell Extras -- -- Supporting library, providing common types and utilities used by the -- various libraries built on top of distributed-process @package distributed-process-extras @version 0.3.7 module Control.Concurrent.Utils -- | Opaque lock. data Lock -- | Create exclusive lock. Only one process could take such lock. mkExclusiveLock :: IO Lock -- | Create quantity lock. A fixed number of processes can take this lock -- simultaniously. mkQLock :: Int -> IO Lock -- | Run action under a held lock. withLock :: (MonadMask m, MonadIO m) => Lock -> m a -> m a module Control.Distributed.Process.Extras.Internal.Containers.MultiMap -- | Opaque type of MultiMaps. data MultiMap k v -- | Class of things that can be inserted in a map or a set (of mapped -- values), for which instances of Eq and Hashable must -- be present. class (Eq a, Hashable a) => Insertable a empty :: MultiMap k v insert :: forall k v. (Insertable k, Insertable v) => k -> v -> MultiMap k v -> MultiMap k v member :: Insertable k => k -> MultiMap k a -> Bool lookup :: Insertable k => k -> MultiMap k v -> Maybe [v] delete :: Insertable k => k -> MultiMap k v -> Maybe ([v], MultiMap k v) filter :: forall k v. Insertable k => (v -> Bool) -> MultiMap k v -> MultiMap k v filterWithKey :: forall k v. Insertable k => (k -> v -> Bool) -> MultiMap k v -> MultiMap k v -- | O(n) Reduce this map by applying a binary operator to all -- elements, using the given starting value (typically the right-identity -- of the operator). foldrWithKey :: (k -> v -> a -> a) -> a -> MultiMap k v -> a toList :: MultiMap k v -> [(k, v)] size :: MultiMap k v -> Int instance Data.Foldable.Foldable (Control.Distributed.Process.Extras.Internal.Containers.MultiMap.MultiMap k) instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a) => Control.Distributed.Process.Extras.Internal.Containers.MultiMap.Insertable a module Control.Distributed.Process.Extras.Internal.Queue.PriorityQ newtype PriorityQ k a PriorityQ :: PQueue k a -> PriorityQ k a [q] :: PriorityQ k a -> PQueue k a empty :: Ord k => PriorityQ k v isEmpty :: Ord k => PriorityQ k v -> Bool singleton :: Ord k => k -> a -> PriorityQ k a enqueue :: Ord k => k -> v -> PriorityQ k v -> PriorityQ k v dequeue :: Ord k => PriorityQ k v -> Maybe (v, PriorityQ k v) peek :: Ord k => PriorityQ k v -> Maybe v module Control.Distributed.Process.Extras.Internal.Queue.SeqQ data SeqQ a empty :: SeqQ a isEmpty :: SeqQ a -> Bool singleton :: a -> SeqQ a enqueue :: SeqQ a -> a -> SeqQ a dequeue :: SeqQ a -> Maybe (a, SeqQ a) peek :: SeqQ a -> Maybe a filter :: (a -> Bool) -> SeqQ a -> SeqQ a size :: SeqQ a -> Int instance GHC.Show.Show a => GHC.Show.Show (Control.Distributed.Process.Extras.Internal.Queue.SeqQ.SeqQ a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Control.Distributed.Process.Extras.Internal.Queue.SeqQ.SeqQ a) -- | Types used throughout the Extras package module Control.Distributed.Process.Extras.Internal.Types -- | Tags provide uniqueness for messages, so that they can be matched with -- their response. type Tag = Int -- | Generates unique Tag for messages and response pairs. Each -- process that depends, directly or indirectly, on the call mechanisms -- in Control.Distributed.Process.Global.Call should have at most -- one TagPool on which to draw unique message tags. type TagPool = MVar Tag -- | Create a new per-process source of unique message identifiers. newTagPool :: Process TagPool -- | Extract a new identifier from a TagPool. getTag :: TagPool -> Process Tag -- | Class of things to which a Process can link itself. class Linkable a -- | Create a link with the supplied object. linkTo :: (Linkable a, Resolvable a) => a -> Process () -- | Class of things that can be killed (or instructed to exit). class Killable p -- | Kill (instruct to exit) generic process, using kill primitive. killProc :: (Killable p, Resolvable p) => p -> String -> Process () -- | Kill (instruct to exit) generic process, using exit primitive. exitProc :: (Killable p, Resolvable p, Serializable m) => p -> m -> Process () -- | Class of things that can be resolved to a ProcessId. class Resolvable a -- | Resolve the reference to a process id, or Nothing if -- resolution fails resolve :: Resolvable a => a -> Process (Maybe ProcessId) -- | Unresolvable Addressable Message unresolvableMessage :: (Resolvable a, Resolvable a) => a -> String -- | Class of things that you can route/send serializable message to class Routable a -- | Send a message to the target asynchronously sendTo :: (Routable a, Serializable m, Resolvable a) => a -> m -> Process () -- | Send some NFData message to the target asynchronously, -- forcing evaluation (i.e., deepseq) beforehand. unsafeSendTo :: (Routable a, NFSerializable m, Resolvable a) => a -> m -> Process () class Monitored a r m | a r -> m mkMonitor :: Monitored a r m => a -> Process r checkMonitor :: Monitored a r m => a -> r -> m -> Process Bool class (Resolvable a, Routable a) => Addressable a -- | A simple means of mapping to a receiver. data Recipient Pid :: !ProcessId -> Recipient Registered :: !String -> Recipient RemoteRegistered :: !String -> !NodeId -> Recipient -- | Used internally in whereisOrStart. Sent as (RegisterSelf,ProcessId). data RegisterSelf RegisterSelf :: RegisterSelf -- | A synchronous version of whereis, this monitors the remote node -- and returns Nothing if the node goes down (since a remote -- node failing or being non-contactible has the same effect as a process -- not being registered from the caller's point of view). whereisRemote :: NodeId -> String -> Process (Maybe ProcessId) -- | resolve the Resolvable or die with specified msg plus details of what -- didn't resolve resolveOrDie :: Resolvable a => a -> String -> Process ProcessId -- | Wait cancellation message. data CancelWait CancelWait :: CancelWait -- | Simple representation of a channel. type Channel a = (SendPort a, ReceivePort a) -- | A ubiquitous shutdown signal that can be used to maintain a -- consistent shutdown/stop protocol for any process that wishes to -- handle it. data Shutdown Shutdown :: Shutdown -- | Provides a reason for process termination. data ExitReason -- | indicates normal exit ExitNormal :: ExitReason -- | normal response to a Shutdown ExitShutdown :: ExitReason -- | abnormal (error) shutdown ExitOther :: !String -> ExitReason -- | Given when a server is unobtainable. newtype ServerDisconnected ServerDisconnected :: DiedReason -> ServerDisconnected -- | Introduces a class that brings NFData into scope along with -- Serializable, such that we can force evaluation. Intended for use with -- the UnsafePrimitives module (which wraps -- Control.Distributed.Process.UnsafePrimitives), and guarantees -- evaluatedness in terms of NFData. Please note that we -- cannot guarantee that an NFData instance will behave -- the same way as a Binary one with regards evaluation, so it -- is still possible to introduce unexpected behaviour by using -- unsafe primitives in this way. class (NFData a, Serializable a) => NFSerializable a instance GHC.Generics.Generic Control.Distributed.Process.Extras.Internal.Types.CancelWait instance GHC.Show.Show Control.Distributed.Process.Extras.Internal.Types.CancelWait instance GHC.Classes.Eq Control.Distributed.Process.Extras.Internal.Types.CancelWait instance GHC.Generics.Generic Control.Distributed.Process.Extras.Internal.Types.RegisterSelf instance GHC.Classes.Eq Control.Distributed.Process.Extras.Internal.Types.Shutdown instance GHC.Show.Show Control.Distributed.Process.Extras.Internal.Types.Shutdown instance GHC.Generics.Generic Control.Distributed.Process.Extras.Internal.Types.Shutdown instance GHC.Show.Show Control.Distributed.Process.Extras.Internal.Types.ExitReason instance GHC.Classes.Eq Control.Distributed.Process.Extras.Internal.Types.ExitReason instance GHC.Generics.Generic Control.Distributed.Process.Extras.Internal.Types.ExitReason instance GHC.Classes.Eq Control.Distributed.Process.Extras.Internal.Types.Recipient instance GHC.Show.Show Control.Distributed.Process.Extras.Internal.Types.Recipient instance GHC.Generics.Generic Control.Distributed.Process.Extras.Internal.Types.Recipient instance GHC.Generics.Generic Control.Distributed.Process.Extras.Internal.Types.ServerDisconnected instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Internal.Types.ServerDisconnected instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Internal.Types.ServerDisconnected instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Internal.Types.Recipient instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Internal.Types.Recipient instance Control.Distributed.Process.Extras.Internal.Types.Resolvable Control.Distributed.Process.Extras.Internal.Types.Recipient instance Control.Distributed.Process.Extras.Internal.Types.Routable Control.Distributed.Process.Extras.Internal.Types.Recipient instance Control.Distributed.Process.Extras.Internal.Types.Addressable Control.Distributed.Process.Internal.Types.ProcessId instance Control.Distributed.Process.Extras.Internal.Types.Routable Control.Distributed.Process.Internal.Types.ProcessId instance Control.Distributed.Process.Extras.Internal.Types.Routable GHC.Base.String instance Control.Distributed.Process.Extras.Internal.Types.Routable (Control.Distributed.Process.Internal.Types.NodeId, GHC.Base.String) instance Control.Distributed.Process.Extras.Internal.Types.Routable (Control.Distributed.Process.Internal.Types.Message -> Control.Distributed.Process.Internal.Types.Process ()) instance Control.Distributed.Process.Extras.Internal.Types.Resolvable p => Control.Distributed.Process.Extras.Internal.Types.Killable p instance Control.Distributed.Process.Extras.Internal.Types.Resolvable a => Control.Distributed.Process.Extras.Internal.Types.Monitored a Control.Distributed.Process.Internal.Types.MonitorRef Control.Distributed.Process.Internal.Types.ProcessMonitorNotification instance Control.Distributed.Process.Extras.Internal.Types.Resolvable Control.Distributed.Process.Internal.Types.ProcessId instance Control.Distributed.Process.Extras.Internal.Types.Resolvable GHC.Base.String instance Control.Distributed.Process.Extras.Internal.Types.Resolvable (Control.Distributed.Process.Internal.Types.NodeId, GHC.Base.String) instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Internal.Types.ExitReason instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Internal.Types.ExitReason instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Internal.Types.Shutdown instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Internal.Types.Shutdown instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Internal.Types.RegisterSelf instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Internal.Types.RegisterSelf instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Internal.Types.CancelWait instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Internal.Types.CancelWait instance (Control.DeepSeq.NFData a, Control.Distributed.Process.Serializable.Serializable a) => Control.Distributed.Process.Extras.Internal.Types.NFSerializable a instance Control.Distributed.Process.Extras.Internal.Types.NFSerializable a => Control.Distributed.Process.Extras.Internal.Types.NFSerializable (Control.Distributed.Process.Internal.Types.SendPort a) -- | This module provides a set of additional primitives that add -- functionality to the basic Cloud Haskell APIs. module Control.Distributed.Process.Extras.Internal.Primitives class (Resolvable a, Routable a) => Addressable a -- | Class of things that you can route/send serializable message to class Routable a -- | Send a message to the target asynchronously sendTo :: (Routable a, Serializable m, Resolvable a) => a -> m -> Process () -- | Send some NFData message to the target asynchronously, -- forcing evaluation (i.e., deepseq) beforehand. unsafeSendTo :: (Routable a, NFSerializable m, Resolvable a) => a -> m -> Process () -- | Class of things that can be resolved to a ProcessId. class Resolvable a -- | Resolve the reference to a process id, or Nothing if -- resolution fails resolve :: Resolvable a => a -> Process (Maybe ProcessId) -- | Unresolvable Addressable Message unresolvableMessage :: (Resolvable a, Resolvable a) => a -> String -- | Class of things to which a Process can link itself. class Linkable a -- | Create a link with the supplied object. linkTo :: (Linkable a, Resolvable a) => a -> Process () -- | Class of things that can be killed (or instructed to exit). class Killable p -- | Kill (instruct to exit) generic process, using kill primitive. killProc :: (Killable p, Resolvable p) => p -> String -> Process () -- | Kill (instruct to exit) generic process, using exit primitive. exitProc :: (Killable p, Resolvable p, Serializable m) => p -> m -> Process () class Monitored a r m | a r -> m mkMonitor :: Monitored a r m => a -> Process r checkMonitor :: Monitored a r m => a -> r -> m -> Process Bool -- | Spawn a new (local) process. This variant takes an initialisation -- action and a secondary expression from the result of the -- initialisation to Process (). The spawn operation -- synchronises on the completion of the before action, such -- that the calling process is guaranteed to only see the newly spawned -- ProcessId once the initialisation has successfully completed. spawnSignalled :: Process a -> (a -> Process ()) -> Process ProcessId -- | Node local version of spawnLink. Note that this is just the -- sequential composition of spawn and link. (The -- Unified semantics that underlies Cloud Haskell does not even -- support a synchronous link operation) spawnLinkLocal :: Process () -> Process ProcessId -- | Like spawnLinkLocal, but monitors the spawned process. spawnMonitorLocal :: Process () -> Process (ProcessId, MonitorRef) -- | CH's link primitive, unlike Erlang's, will trigger when the -- target process dies for any reason. This function has semantics like -- Erlang's: it will trigger ProcessLinkException only when the -- target dies abnormally. linkOnFailure :: ProcessId -> Process () -- | A synchronous version of whereis, this monitors the remote node -- and returns Nothing if the node goes down (since a remote -- node failing or being non-contactible has the same effect as a process -- not being registered from the caller's point of view). whereisRemote :: NodeId -> String -> Process (Maybe ProcessId) -- | Returns the pid of the process that has been registered under the -- given name. This refers to a local, per-node registration, not -- global registration. If that name is unregistered, a process -- is started. This is a handy way to start per-node named servers. whereisOrStart :: String -> Process () -> Process ProcessId -- | A remote equivalent of whereisOrStart. It deals with the node -- registry on the given node, and the process, if it needs to be -- started, will run on that node. If the node is inaccessible, Nothing -- will be returned. whereisOrStartRemote :: NodeId -> String -> Closure (Process ()) -> Process (Maybe ProcessId) -- | An alternative to matchIf that allows both predicate and action -- to be expressed in one parameter. matchCond :: Serializable a => (a -> Maybe (Process b)) -> Match b -- | Safe (i.e., monitored) waiting on an expected response/message. awaitResponse :: Addressable a => a -> [Match (Either ExitReason b)] -> Process (Either ExitReason b) -- | Apply the supplied expression n times -- | Deprecated: use replicateM_ instead times :: Int -> Process () -> Process () -- | Monitor any Resolvable object. monitor :: Resolvable a => a -> Process (Maybe MonitorRef) -- | Wait until Resolvable object will exit. Return immediately if -- object can't be resolved. awaitExit :: Resolvable a => a -> Process () -- | Check if specified process is alive. Information may be outdated. isProcessAlive :: ProcessId -> Process Bool -- | Like forever but sans space leak forever' :: Monad m => m a -> m b -- | Send message to Addressable object. deliver :: (Addressable a, Serializable m) => m -> a -> Process () __remoteTable :: RemoteTable -> RemoteTable -- | If you don't know exactly what this module is for and precisely how to -- use the types within, you should move on, quickly! -- --
-- receiveTimeout (after 3 Seconds) [ match (\"ok" -> return ()) ] --after :: Int -> TimeUnit -> Int -- | Convenience for making TimeInterval; e.g., -- --
-- let ti = within 5 Seconds in ..... --within :: Int -> TimeUnit -> TimeInterval -- | converts the supplied TimeUnit to microseconds timeToMicros :: TimeUnit -> Int -> Int -- | A time interval. data TimeInterval -- | Defines the time unit for a Timeout value data TimeUnit Days :: TimeUnit Hours :: TimeUnit Minutes :: TimeUnit Seconds :: TimeUnit Millis :: TimeUnit Micros :: TimeUnit -- | Represents either a delay of TimeInterval, an infinite wait or -- no delay (i.e., non-blocking). data Delay Delay :: TimeInterval -> Delay Infinity :: Delay NoDelay :: Delay -- | given a TimeInterval, provide an equivalent -- NominalDiffTim timeIntervalToDiffTime :: TimeInterval -> NominalDiffTime -- | given a NominalDiffTim, provide an equivalent -- TimeInterval@ diffTimeToTimeInterval :: NominalDiffTime -> TimeInterval -- | given a NominalDiffTim, provide an equivalent Delay@ diffTimeToDelay :: NominalDiffTime -> Delay -- | given a Delay, provide an equivalent NominalDiffTim delayToDiffTime :: Delay -> NominalDiffTime -- | Create a NominalDiffTime from a number of microseconds. microsecondsToNominalDiffTime :: Integer -> NominalDiffTime -- | Represents a timeout in terms of microseconds, where -- Nothing stands for infinity and Just 0, no-delay. type Timeout = Maybe Int -- | Send to a process when a timeout expires. data TimeoutNotification TimeoutNotification :: Tag -> TimeoutNotification -- | Sends the calling process TimeoutNotification tag after -- time microseconds timeout :: Int -> Tag -> ProcessId -> Process () -- | Constructs an inifinite Timeout. infiniteWait :: Timeout -- | Constructs a no-wait Timeout noWait :: Timeout instance GHC.Show.Show Control.Distributed.Process.Extras.Time.TimeUnit instance GHC.Classes.Eq Control.Distributed.Process.Extras.Time.TimeUnit instance GHC.Generics.Generic Control.Distributed.Process.Extras.Time.TimeUnit instance GHC.Show.Show Control.Distributed.Process.Extras.Time.TimeInterval instance GHC.Classes.Eq Control.Distributed.Process.Extras.Time.TimeInterval instance GHC.Generics.Generic Control.Distributed.Process.Extras.Time.TimeInterval instance GHC.Show.Show Control.Distributed.Process.Extras.Time.Delay instance GHC.Classes.Eq Control.Distributed.Process.Extras.Time.Delay instance GHC.Generics.Generic Control.Distributed.Process.Extras.Time.Delay instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Time.TimeoutNotification instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Time.Delay instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Time.Delay instance GHC.Num.Num Control.Distributed.Process.Extras.Time.Delay instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Time.TimeInterval instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Time.TimeInterval instance GHC.Num.Num Control.Distributed.Process.Extras.Time.TimeInterval instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Time.TimeUnit instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Time.TimeUnit -- |
-- systemLogFile :: FilePath -> LogLevel -> LogFormat -> Process ProcessId -- systemLogFile path lvl fmt = do -- h <- liftIO $ openFile path AppendMode -- liftIO $ hSetBuffering h LineBuffering -- systemLog (liftIO . hPutStrLn h) (liftIO (hClose h)) lvl fmt --module Control.Distributed.Process.Extras.SystemLog data LogLevel Debug :: LogLevel Info :: LogLevel Notice :: LogLevel Warning :: LogLevel Error :: LogLevel Critical :: LogLevel Alert :: LogLevel Emergency :: LogLevel type LogFormat = String -> Process String data LogClient data LogChan type LogText = String class ToLog m toLog :: (ToLog m, Serializable m) => m -> Process (LogLevel -> LogMessage) class Logger a logMessage :: Logger a => a -> LogMessage -> Process () mxLogId :: MxAgentId -- | Start a system logger process as a management agent. systemLog :: (String -> Process ()) -> Process () -> LogLevel -> LogFormat -> Process ProcessId client :: Process (Maybe LogClient) logChannel :: LogChan addFormatter :: Addressable r => r -> Closure (Message -> Process (Maybe String)) -> Process () -- | Start a system logger that writes to a file. -- -- This is a very basic file logging facility, that uses -- regular buffered file I/O (i.e., System.IO.hPutStrLn -- et al) under the covers. The handle is closed appropriately if/when -- the logging process terminates. -- -- See -- Control.Distributed.Process.Management.mxAgentWithFinalize -- for futher details about management agents that use finalizers. systemLogFile :: FilePath -> LogLevel -> LogFormat -> Process ProcessId report :: Logger l => (l -> LogText -> Process ()) -> l -> String -> Process () debug :: (Logger l, Serializable m, ToLog m) => l -> m -> Process () info :: (Logger l, Serializable m, ToLog m) => l -> m -> Process () notice :: (Logger l, Serializable m, ToLog m) => l -> m -> Process () warning :: (Logger l, Serializable m, ToLog m) => l -> m -> Process () error :: (Logger l, Serializable m, ToLog m) => l -> m -> Process () critical :: (Logger l, Serializable m, ToLog m) => l -> m -> Process () alert :: (Logger l, Serializable m, ToLog m) => l -> m -> Process () emergency :: (Logger l, Serializable m, ToLog m) => l -> m -> Process () sendLog :: (Logger l, Serializable m, ToLog m) => l -> m -> LogLevel -> Process () instance GHC.Enum.Enum Control.Distributed.Process.Extras.SystemLog.LogLevel instance GHC.Classes.Ord Control.Distributed.Process.Extras.SystemLog.LogLevel instance GHC.Show.Show Control.Distributed.Process.Extras.SystemLog.LogLevel instance GHC.Read.Read Control.Distributed.Process.Extras.SystemLog.LogLevel instance GHC.Classes.Eq Control.Distributed.Process.Extras.SystemLog.LogLevel instance GHC.Generics.Generic Control.Distributed.Process.Extras.SystemLog.LogLevel instance GHC.Generics.Generic Control.Distributed.Process.Extras.SystemLog.SetLevel instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.SystemLog.AddFormatter instance GHC.Generics.Generic Control.Distributed.Process.Extras.SystemLog.AddFormatter instance GHC.Show.Show Control.Distributed.Process.Extras.SystemLog.LogMessage instance GHC.Generics.Generic Control.Distributed.Process.Extras.SystemLog.LogMessage instance Control.Distributed.Process.Extras.SystemLog.Logger Control.Distributed.Process.Extras.SystemLog.LogClient instance Control.Distributed.Process.Extras.SystemLog.Logger Control.Distributed.Process.Extras.SystemLog.LogChan instance Control.Distributed.Process.Extras.SystemLog.ToLog Control.Distributed.Process.Extras.SystemLog.LogText instance Control.Distributed.Process.Extras.SystemLog.ToLog Control.Distributed.Process.Internal.Types.Message instance Control.Distributed.Process.Extras.Internal.Types.Resolvable Control.Distributed.Process.Extras.SystemLog.LogClient instance Control.Distributed.Process.Extras.Internal.Types.Routable Control.Distributed.Process.Extras.SystemLog.LogClient instance Control.Distributed.Process.Extras.Internal.Types.Routable Control.Distributed.Process.Extras.SystemLog.LogChan instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.SystemLog.LogMessage instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.SystemLog.LogMessage instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.SystemLog.AddFormatter instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.SystemLog.SetLevel instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.SystemLog.SetLevel instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.SystemLog.LogLevel instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.SystemLog.LogLevel -- | This module provides a primitive node monitoring capability, -- implemented as a distributed-process Management Agent. Once the -- nodeMonitor agent is started, calling monitorNodes will -- ensure that whenever the local node detects a new network-transport -- connection (from another cloud haskell node), the caller will receive -- a NodeUp message in its mailbox. If a node disconnects, a -- corollary NodeDown message will be delivered as well. module Control.Distributed.Process.Extras.Monitoring -- | Sent to subscribing processes when a connection (from a remote node) -- is detected. data NodeUp NodeUp :: !NodeId -> NodeUp -- | Sent to subscribing processes when a dis-connection (from a remote -- node) is detected. data NodeDown NodeDown :: !NodeId -> NodeDown -- | The MxAgentId for the node monitoring agent. nodeMonitorAgentId :: MxAgentId -- | Starts the node monitoring agent. No call to monitorNodes and -- unmonitorNodes will have any effect unless the agent is -- already running. Note that we make no guarantees what-so-ever -- about the timeliness or ordering semantics of node monitoring -- notifications. nodeMonitor :: Process ProcessId -- | Start monitoring node connection/disconnection events. When a -- connection event occurs, the calling process will receive a message -- NodeUp NodeId in its mailbox. When a disconnect occurs, the -- corollary NodeDown NodeId message will be delivered instead. -- -- No guaranatee is made about the timeliness of the delivery, nor can -- the receiver expect that the node (for which it is being notified) is -- still upconnected or downdisconnected at the point when it -- receives a message from the node monitoring agent. monitorNodes :: Process () -- | Stop monitoring node connection/disconnection events. This does not -- flush the caller's mailbox, nor does it guarantee that any/all node -- up/down notifications will have been delivered before it is evaluated. unmonitorNodes :: Process () instance GHC.Generics.Generic Control.Distributed.Process.Extras.Monitoring.Register instance GHC.Generics.Generic Control.Distributed.Process.Extras.Monitoring.UnRegister instance GHC.Show.Show Control.Distributed.Process.Extras.Monitoring.NodeUp instance GHC.Generics.Generic Control.Distributed.Process.Extras.Monitoring.NodeUp instance GHC.Show.Show Control.Distributed.Process.Extras.Monitoring.NodeDown instance GHC.Generics.Generic Control.Distributed.Process.Extras.Monitoring.NodeDown instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Monitoring.NodeDown instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Monitoring.NodeDown instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Monitoring.NodeUp instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Monitoring.NodeUp instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Monitoring.UnRegister instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Monitoring.UnRegister instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Monitoring.Register instance Control.DeepSeq.NFData Control.Distributed.Process.Extras.Monitoring.Register -- | This module provides a facility for Remote Procedure Call (rpc) style -- interactions with Cloud Haskell processes. -- -- Clients make synchronous calls to a running process (i.e., server) -- using the callAt, callTimeout and multicall -- functions. Processes acting as the server are constructed using Cloud -- Haskell's receive family of primitives and the -- callResponse family of functions in this module. module Control.Distributed.Process.Extras.Call -- | Like callTimeout, but with no timeout. Returns Nothing if the -- target process dies. callAt :: (Serializable a, Serializable b) => ProcessId -> a -> Tag -> Process (Maybe b) -- | Sends a message of type a to the given process, to be handled by a -- corresponding callResponse... function, which will send back a message -- of type b. The tag is per-process unique identifier of the -- transaction. If the timeout expires or the target process dies, -- Nothing will be returned. callTimeout :: (Serializable a, Serializable b) => ProcessId -> a -> Tag -> Timeout -> Process (Maybe b) -- | Like callTimeout, but sends the message to multiple recipients -- and collects the results. multicall :: forall a b. (Serializable a, Serializable b) => [ProcessId] -> a -> Tag -> Timeout -> Process [Maybe b] -- | Produces a Match that can be used with the receiveWait family -- of message-receiving functions. callResponse will respond to -- a message of type a sent by callTimeout, and will respond with -- a value of type b. callResponse :: (Serializable a, Serializable b) => (a -> Process (b, c)) -> Match c callResponseIf :: (Serializable a, Serializable b) => (a -> Bool) -> (a -> Process (b, c)) -> Match c callResponseDefer :: (Serializable a, Serializable b) => (a -> (b -> Process ()) -> Process c) -> Match c callResponseDeferIf :: (Serializable a, Serializable b) => (a -> Bool) -> (a -> (b -> Process ()) -> Process c) -> Match c -- | Produces a Match that can be used with the receiveWait family -- of message-receiving functions. When calllForward receives a message -- of type from from callTimeout (and similar), it will forward -- the message to another process, who will be responsible for responding -- to it. It is the user's responsibility to ensure that the forwarding -- process is linked to the destination process, so that if it fails, the -- sender will be notified. callForward :: Serializable a => (a -> (ProcessId, c)) -> Match c -- | The message handling code is started in a separate thread. It's not -- automatically linked to the calling thread, so if you want it to be -- terminated when the message handling thread dies, you'll need to call -- link yourself. callResponseAsync :: (Serializable a, Serializable b) => (a -> Maybe c) -> (a -> Process b) -> Match c instance GHC.Classes.Eq a => GHC.Classes.Eq (Control.Distributed.Process.Extras.Call.MulticallResponseType a) instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Call.MulticallResponse instance Data.Binary.Class.Binary Control.Distributed.Process.Extras.Call.Multicall