| Copyright | (c) Tim Watson 2013, Parallel Scientific (Jeff Epstein) 2012 |
|---|---|
| License | BSD3 (see the file LICENSE) |
| Safe Haskell | None |
| Language | Haskell98 |
Control.Distributed.Process.Extras.Internal.Primitives
Contents
Description
Maintainers : Jeff Epstein, Tim Watson Stability : experimental Portability : non-portable (requires concurrency)
This module provides a set of additional primitives that add functionality to the basic Cloud Haskell APIs.
- class (Resolvable a, Routable a) => Addressable a
- class Routable a where
- sendTo :: Serializable m => a -> m -> Process ()
- unsafeSendTo :: NFSerializable m => a -> m -> Process ()
- unresolvableMessage :: a -> String
- class Resolvable a where
- class Linkable a where
- class Killable a where
- spawnSignalled :: Process a -> (a -> Process ()) -> Process ProcessId
- spawnLinkLocal :: Process () -> Process ProcessId
- spawnMonitorLocal :: Process () -> Process (ProcessId, MonitorRef)
- linkOnFailure :: ProcessId -> Process ()
- whereisRemote :: NodeId -> String -> Process (Maybe ProcessId)
- whereisOrStart :: String -> Process () -> Process ProcessId
- whereisOrStartRemote :: NodeId -> String -> Closure (Process ()) -> Process (Maybe ProcessId)
- matchCond :: Serializable a => (a -> Maybe (Process b)) -> Match b
- awaitResponse :: Addressable a => a -> [Match (Either ExitReason b)] -> Process (Either ExitReason b)
- times :: Int -> Process () -> Process ()
- monitor :: Resolvable a => a -> Process (Maybe MonitorRef)
- awaitExit :: Resolvable a => a -> Process ()
- isProcessAlive :: ProcessId -> Process Bool
- forever' :: Monad m => m a -> m b
- deliver :: (Addressable a, Serializable m) => m -> a -> Process ()
- __remoteTable :: RemoteTable -> RemoteTable
General Purpose Process Addressing
class (Resolvable a, Routable a) => Addressable a Source
Instances
| (Resolvable a, Routable a) => Addressable a Source |
Provides a unified API for addressing processes.
Minimal complete definition
Methods
sendTo :: Serializable m => a -> m -> Process () Source
Send a message to the target asynchronously
unsafeSendTo :: NFSerializable m => a -> m -> Process () Source
Send some NFData message to the target asynchronously,
forcing evaluation (i.e., deepseq) beforehand.
unresolvableMessage :: a -> String Source
Unresolvable Addressable Message
class Resolvable a where Source
Class of things that can be resolved to a ProcessId.
Class of things to which a Process can link itself.
Class of things that can be killed (or instructed to exit).
Spawning and Linking
spawnSignalled :: Process a -> (a -> Process ()) -> Process ProcessId Source
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.
spawnLinkLocal :: Process () -> Process ProcessId Source
spawnMonitorLocal :: Process () -> Process (ProcessId, MonitorRef) Source
Like spawnLinkLocal, but monitors the spawned process.
linkOnFailure :: ProcessId -> Process () Source
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.
Registered Processes
whereisOrStart :: String -> Process () -> Process ProcessId Source
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.
whereisOrStartRemote :: NodeId -> String -> Closure (Process ()) -> Process (Maybe ProcessId) Source
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.
Selective Receive/Matching
matchCond :: Serializable a => (a -> Maybe (Process b)) -> Match b Source
An alternative to matchIf that allows both predicate and action
to be expressed in one parameter.
awaitResponse :: Addressable a => a -> [Match (Either ExitReason b)] -> Process (Either ExitReason b) Source
Safe (i.e., monitored) waiting on an expected response/message.
General Utilities
monitor :: Resolvable a => a -> Process (Maybe MonitorRef) Source
Monitor any Resolvable object.
awaitExit :: Resolvable a => a -> Process () Source
isProcessAlive :: ProcessId -> Process Bool Source
deliver :: (Addressable a, Serializable m) => m -> a -> Process () Source