Holumbus-Distribution-0.1.1: intra- and inter-program communication

Portabilityportable
Stabilityexperimental
MaintainerStefan Schmidt (stefanschmidt@web.de)

Holumbus.Distribution.DStreamPort

Contents

Description

Version : 0.1

This module offers distributed streams and ports.

Because a DChan allows external read access, the idea came up to split a DChan into two parts: a stream and a port. A stream only allows you to read data from it. The read-access is limited to the local process which created the stream. To send data to a stream, you need a port. This can be used on forgein nodes to send data to your local stream.

Synopsis

datatypes

data DPort a Source

Instances

Binary a => Binary (DPort a) 

data Binary a => StreamPortMessage a Source

Message Datatype. We are sending additional information, to do debugging

Constructors

StreamPortMessage 

Fields

spm_Data :: !a

the data

spm_Generic :: !(Maybe ByteString)

some generic data -- could be another port

Instances

creating and closing a stream

newDStream :: Binary a => String -> IO (DStream a)Source

Creates a new local stream.

closeDStream :: DStream a -> IO ()Source

Closes a stream.

operations on a stream

isEmptyDStream :: DStream a -> IO BoolSource

Tests, if a stream has no more data to read.

receive :: Binary a => DStream a -> IO aSource

Reads the data packet of the next message from a stream. If stream is empty, this function will block until a new message arrives.

receiveMsg :: Binary a => DStream a -> IO (StreamPortMessage a)Source

Reads the next message from a stream (data packet + message header). If stream is empty, this function will block until a new message arrives.

tryReceive :: Binary a => DStream a -> IO (Maybe a)Source

Reads the data packet of the next message from a stream. If stream is empty, this function will immediately return with Nothing.

tryReceiveMsg :: Binary a => DStream a -> IO (Maybe (StreamPortMessage a))Source

Reads the next message from a stream (data packet + message header). If stream is empty, this function will immediately return with Nothing.

tryWaitReceive :: Binary a => DStream a -> Int -> IO (Maybe a)Source

Reads the data packet of the next message from a stream. If stream is empty, this function will wait for new messages until the time is up and if no message has arrived, return with Nothing.

tryWaitReceiveMsg :: Binary a => DStream a -> Int -> IO (Maybe (StreamPortMessage a))Source

Reads the next message from a stream (data packet + message header). If stream is empty, this function will wait for new messages until the time is up and if no message has arrived, return with Nothing.

withStream :: Binary a => (DStream a -> IO b) -> IO bSource

Encapsulates a stream. A new stream is created, then some user-action is done an after that the stream is closed.

creating a port

newDPortFromStream :: DStream a -> IO (DPort a)Source

Creates a new Port, which is bound to a stream.

newDPort :: String -> String -> IO (DPort a)Source

Creates a new port from a streamname and its socketId. The first parameter is the name of the resource and the second one the name of the node.

operations on a port

send :: Binary a => DPort a -> a -> IO ()Source

Send data to the stream of the port. The data is send via network, if the stream is located on an external processor

sendWithGeneric :: Binary a => DPort a -> a -> ByteString -> IO ()Source

Like send, but here we can give some generic data (e.g. a port for reply messages).

sendWithMaybeGeneric :: Binary a => DPort a -> a -> Maybe ByteString -> IO ()Source

Like sendWithGeneric, but the generic data is optional