|Maintainer||Stefan Schmidt (email@example.com)|
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
- newDChan :: Binary a => String -> IO (DChan a)
- newRemoteDChan :: String -> String -> IO (DChan a)
- closeDChan :: DChan a -> IO ()
- writeDChan :: Binary a => DChan a -> a -> IO ()
- readDChan :: Binary a => DChan a -> IO a
- tryReadDChan :: Binary a => DChan a -> IO (Maybe a)
- tryWaitReadDChan :: Binary a => DChan a -> Int -> IO (Maybe a)
- isEmptyDChan :: DChan a -> IO Bool
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
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.
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.
Closes a DChan object, could not be used anymore after this call.
operations on a channel
Tries to read data from a DChan, if the DChan is empty, the function return with Nothing.
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.