Holumbus-Distribution-0.1.0: intra- and inter-program communicationSource codeContentsIndex
Holumbus.Distribution.DStreamPort
Portabilityportable
Stabilityexperimental
MaintainerStefan Schmidt (stefanschmidt@web.de)
Contents
datatypes
creating and closing a stream
operations on a stream
creating a port
operations on a port
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
data DStream a
data DPort a
data Binary a => StreamPortMessage a = StreamPortMessage {
spm_Data :: !a
spm_Generic :: !(Maybe ByteString)
}
newDStream :: Binary a => String -> IO (DStream a)
closeDStream :: DStream a -> IO ()
isEmptyDStream :: DStream a -> IO Bool
receive :: Binary a => DStream a -> IO a
receiveMsg :: Binary a => DStream a -> IO (StreamPortMessage a)
tryReceive :: Binary a => DStream a -> IO (Maybe a)
tryReceiveMsg :: Binary a => DStream a -> IO (Maybe (StreamPortMessage a))
tryWaitReceive :: Binary a => DStream a -> Int -> IO (Maybe a)
tryWaitReceiveMsg :: Binary a => DStream a -> Int -> IO (Maybe (StreamPortMessage a))
withStream :: Binary a => (DStream a -> IO b) -> IO b
newDPortFromStream :: DStream a -> IO (DPort a)
newDPort :: String -> String -> IO (DPort a)
send :: Binary a => DPort a -> a -> IO ()
sendWithGeneric :: Binary a => DPort a -> a -> ByteString -> IO ()
sendWithMaybeGeneric :: Binary a => DPort a -> a -> Maybe ByteString -> IO ()
datatypes
data DStream a Source
data DPort a Source
show/hide Instances
data Binary a => StreamPortMessage a Source
Message Datatype. We are sending additional information, to do debugging
Constructors
StreamPortMessage
spm_Data :: !athe data
spm_Generic :: !(Maybe ByteString)some generic data -- could be another port
show/hide 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
Produced by Haddock version 2.6.1