Hermes-0.0.4: Message-based middleware layer

Network.Hermes.MChan

Description

An MChan is a combination of a Map and a TChan.

Synopsis

Documentation

data MChan k v Source

MChan is an abstract type representing a keyed, unbounded FIFO channel

Instances

newMChan :: Ord k => STM (MChan k v)Source

Builds and returns a new instance of MChan

newMChanIO :: Ord k => IO (MChan k v)Source

IO version of newMChan. This is useful for creating top-level MChans using System.IO.Unsafe.unsafePerformIO, because using atomically inside System.IO.Unsafe.unsafePerformIO isn't safe.

readMChan :: Ord k => MChan k v -> k -> STM (Maybe v)Source

Read the next value from an MChan. If the specified key doesn't exist (or is removed while waiting), it returns Nothing.

writeMChan :: Ord k => MChan k v -> k -> v -> STM BoolSource

Write a value to an MChan. Returns false and discards the value if the specified key doesn't exist.

writeMChan' :: Ord k => MChan k v -> k -> v -> STM ()Source

Write a value to an MChan, creating the key if it doesn't exist.

existsMChan :: Ord k => MChan k v -> k -> STM BoolSource

Checks whether the key exists

ensureMChan :: Ord k => MChan k v -> k -> STM ()Source

Creates the key if it doesn't already exist

deleteMChan :: Ord k => MChan k v -> k -> STM ()Source

Delete a key from an MChan