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

Portabilityportable
Stabilityexperimental
MaintainerStefan Schmidt (stefanschmidt@web.de)

Holumbus.Distribution.DMVar

Contents

Description

Version : 0.1

This module offers the distributed MVar datatype.

The datatype behaves just like a normal MVar, but the content of the variable may be stored on a different DNode. When accessing the DMVar, the content will be fetched from the external node and written back.

It is guaranteed, that only one node at a time can take the content of the DMVar. Just like normal DMVars, you can produce deadlocks.

When a node dies which holds the content of a DMVar, the node which created the variable will reset its value to the last known value.

If the owner dies, the other nodes cannot access the content of the DMVar any more.

Synopsis

datatype

data DMVar a Source

The DMVar datatype.

Instances

creating and closing DMVars

newDMVar :: Binary a => String -> a -> IO (DMVar a)Source

Creates a new local DMVar with a start value. The string parameter specifies the name of the variable. If you leave it empty, a random value will be generated.

newEmptyDMVar :: Binary a => String -> IO (DMVar a)Source

Creates a new empty local DMVar. The string parameter specifies the name of the variable. If you leave it empty, a random value will be generated.

newRemoteDMVar :: String -> String -> IO (DMVar a)Source

Creates a reference to an external DMVar. The first parameter is the name of the resource and the second one the name of the node.

closeDMVar :: DMVar a -> IO ()Source

Closes a DMVar

acccessing DMVars

readDMVar :: Binary a => DMVar a -> IO aSource

Reads the content of a DMVar. Blocks if the Variable is empty. This may throw an exception if the owner of the variable is unreachable.

takeDMVar :: Binary a => DMVar a -> IO aSource

Takes the content of a DMVar. Blocks if the Variable is empty. This may throw an exception if the owner of the variable is unreachable.

putDMVar :: Binary a => DMVar a -> a -> IO ()Source

Writes a value to the DMvar. Blocks if the Variable is not empty. This may throw an exception if the owner of the variable is unreachable.