caf-0.0.3: A library of Concurrency Abstractions using Futures.

Portabilitynon-portable (requires Futures)



This module implements one-place buffers using futures. Warning: All operations on buffers should only be used within the global wrapper function withFuturesDo!



type Buffer a = (Cell Bool, Cell Bool, Cell a, Cell (Bool -> IO ()))Source

The buffer type contains of 3 cells and a handle. The first 2 cells are for communication of either a put or get is allowed. The thrist cell is the storage cell, the last cell contains a the active handle.

newBuf :: IO (Buffer a)Source

Creates a new empty buffer.

putBuf :: Buffer a -> a -> IO ()Source

Puts a new value to a buffer. putBuf blocks if the buffer is full.

getBuf :: Buffer a -> IO aSource

Gets the contents of a non-empty buffer. If the buffer is empty, then this function blocks until the buffer is filled.