distributed-process-0.7.2: Cloud Haskell: Erlang-style concurrency in Haskell

Copyright(c) Well-Typed / Tim Watson
LicenseBSD3 (see the file LICENSE)
MaintainerTim Watson <watson.timothy@gmail.com>
Stabilityexperimental
Portabilitynon-portable (requires concurrency)
Safe HaskellNone
LanguageHaskell98

Control.Distributed.Process.UnsafePrimitives

Contents

Description

Unsafe Variants of Cloud Haskell's Messaging Primitives

Cloud Haskell's semantics do not mention evaluation/strictness properties at all; Only the promise (or lack) of signal/message delivery between processes is considered. For practical purposes, Cloud Haskell optimises communication between (intra-node) local processes by skipping the network-transport layer. In order to ensure the same strictness semantics however, messages still undergo binary serialisation before (internal) transmission takes place. Thus we ensure that in both (the local and remote) cases, message payloads are fully evaluated. Whilst this provides the user with unsurprising behaviour, the resulting performance overhead is quite severe. Communicating data between Haskell threads without forcing binary serialisation reduces (intra-node, inter-process) communication overheads by several orders of magnitude.

This module provides variants of Cloud Haskell's messaging primitives (send, sendChan, nsend and wrapMessage) which do not force binary serialisation in the local case, thereby offering superior intra-node messaging performance. The catch is that any evaluation problems lurking within the passed data structure (e.g., fields set to undefined and so on) will show up in the receiver rather than in the caller (as they would with the normal strategy).

Use of the functions in this module can potentially change the runtime behaviour of your application. You have been warned!

This module is exported so that you can replace the use of Cloud Haskell's safe messaging primitives. If you want to use both variants, then you can take advantage of qualified imports, however Control.Distributed.Process also re-exports these functions under different names, using the unsafe prefix.

Synopsis

Unsafe Basic Messaging

send :: Serializable a => ProcessId -> a -> Process () Source #

Send a message

sendChan :: Serializable a => SendPort a -> a -> Process () Source #

Send a message on a typed channel

nsend :: Serializable a => String -> a -> Process () Source #

Named send to a process in the local registry (asynchronous)

nsendRemote :: Serializable a => NodeId -> String -> a -> Process () Source #

Named send to a process in a remote registry (asynchronous)

usend :: Serializable a => ProcessId -> a -> Process () Source #

Send a message unreliably.

Unlike send, this function is insensitive to reconnect. It will try to send the message regardless of the history of connection failures between the nodes.

Message passing with usend is ordered for a given sender and receiver if the messages arrive at all.

wrapMessage :: Serializable a => a -> Message Source #

Create an unencoded Message for any Serializable type.