distributed-process-extras-0.3.6: Cloud Haskell Extras
Copyright(c) Tim Watson 2013 - 2017 Parallel Scientific (Jeff Epstein) 2012
LicenseBSD3 (see the file LICENSE)
Stabilityexperimental
Portabilitynon-portable (requires concurrency)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Distributed.Process.Extras.Internal.Primitives

Description

This module provides a set of additional primitives that add functionality to the basic Cloud Haskell APIs.

Synopsis

General Purpose Process Addressing

class (Resolvable a, Routable a) => Addressable a Source #

Instances

Instances details
Addressable ProcessId Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Internal.Types

class Routable a where Source #

Class of things that you can route/send serializable message to

Minimal complete definition

Nothing

Methods

sendTo :: (Serializable m, Resolvable a) => a -> m -> Process () Source #

Send a message to the target asynchronously

unsafeSendTo :: (NFSerializable m, Resolvable a) => a -> m -> Process () Source #

Send some NFData message to the target asynchronously, forcing evaluation (i.e., deepseq) beforehand.

Instances

Instances details
Routable ProcessId Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Internal.Types

Routable Recipient Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Internal.Types

Routable LogChan Source # 
Instance details

Defined in Control.Distributed.Process.Extras.SystemLog

Routable LogClient Source # 
Instance details

Defined in Control.Distributed.Process.Extras.SystemLog

Routable String Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Internal.Types

Routable (NodeId, String) Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Internal.Types

Routable (Message -> Process ()) Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Internal.Types

Methods

sendTo :: (Serializable m, Resolvable (Message -> Process ())) => (Message -> Process ()) -> m -> Process () Source #

unsafeSendTo :: (NFSerializable m, Resolvable (Message -> Process ())) => (Message -> Process ()) -> m -> Process () Source #

class Linkable a where Source #

Class of things to which a Process can link itself.

Minimal complete definition

Nothing

Methods

linkTo :: Resolvable a => a -> Process () Source #

Create a link with the supplied object.

class Killable p where Source #

Class of things that can be killed (or instructed to exit).

Minimal complete definition

Nothing

Methods

killProc :: Resolvable p => p -> String -> Process () Source #

Kill (instruct to exit) generic process, using kill primitive.

exitProc :: (Resolvable p, Serializable m) => p -> m -> Process () Source #

Kill (instruct to exit) generic process, using exit primitive.

Instances

Instances details
Resolvable p => Killable p Source # 
Instance details

Defined in Control.Distributed.Process.Extras.Internal.Types

Methods

killProc :: p -> String -> Process () Source #

exitProc :: (Resolvable p, Serializable m) => p -> m -> Process () Source #

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 #

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)

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

whereisRemote :: NodeId -> String -> Process (Maybe ProcessId) Source #

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).

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

times :: Int -> Process () -> Process () Source #

Deprecated: use replicateM_ instead

Apply the supplied expression n times

monitor :: Resolvable a => a -> Process (Maybe MonitorRef) Source #

Monitor any Resolvable object.

awaitExit :: Resolvable a => a -> Process () Source #

Wait until Resolvable object will exit. Return immediately if object can't be resolved.

isProcessAlive :: ProcessId -> Process Bool Source #

Check if specified process is alive. Information may be outdated.

forever' :: Monad m => m a -> m b Source #

Like forever but sans space leak

deliver :: (Addressable a, Serializable m) => m -> a -> Process () Source #

Send message to Addressable object.

Remote Table