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

MaintainerStefan Schmidt (stefanschmidt@web.de)




Version : 0.1

This module offers a distributed channel datatype (DChan).

It is similar to Control.Concurrent.Chan, except that you can use it between multiple processes on different computers. You can access a DChan (reading and writing) from your local process as well as from another one.



data DChan a Source

The DChan datatype. Notice that this datatype implements the Data.Binary typeclass. That means that you can pass a DChan, so that another computer can access the channel.


creating and closing channels

newDChan :: Binary a => String -> IO (DChan a)Source

Creates a new DChan on the local computer. The first parameter is the name of the Channel which could be used in other processes to access this stream. If you leave it empty, a random Id will be created.

newRemoteDChan :: String -> String -> IO (DChan a)Source

Creates a reference to a DChan which was created in a different process. The first parameter is the name of the resource and the second one the name of the node.

closeDChan :: DChan a -> IO ()Source

Closes a DChan object, could not be used anymore after this call.

operations on a channel

writeDChan :: Binary a => DChan a -> a -> IO ()Source

Writes data to a DChan.

readDChan :: Binary a => DChan a -> IO aSource

Reads data from a DChan, blocks if DChan is empty.

tryReadDChan :: Binary a => DChan a -> IO (Maybe a)Source

Tries to read data from a DChan, if the DChan is empty, the function return with Nothing.

tryWaitReadDChan :: Binary a => DChan a -> Int -> IO (Maybe a)Source

Reads data from a DChan. If the channel is empty, it waits for a given time (in microseconds) an returns immediately when new data arrives, otherwise it return Nothing.

isEmptyDChan :: DChan a -> IO BoolSource

Tests, if a DChan is empty.