strict-concurrency-0.2.4.2: Strict concurrency abstractions

Copyright(c) The University of Glasgow 2001 Don Stewart 2007
LicenseBSD-style
Maintainerdons@galois.com
Stabilityexperimental
Portabilitynon-portable (concurrency)
Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.Chan.Strict

Contents

Description

Unbounded, element-strict channels. Elements will be evaluated to WHNF on entering the channel. For some concurrency applications, this is more desirable than passing an unevaluted thunk through the channel (for instance, it guarantees the node willl be evaluated to WHNF in a worker thead).

Element-strict channes may potentially use more memory than lazy channels

Synopsis

The Chan type

data Chan a Source #

Chan is an abstract type representing an unbounded FIFO channel.

Operations

newChan :: NFData a => IO (Chan a) Source #

Build and returns a new instance of Chan.

writeChan :: NFData a => Chan a -> a -> IO () Source #

Write a value to a Chan.

readChan :: NFData a => Chan a -> IO a Source #

Read the next value from the Chan.

dupChan :: NFData a => Chan a -> IO (Chan a) Source #

Duplicate a Chan: the duplicate channel begins empty, but data written to either channel from then on will be available from both. Hence this creates a kind of broadcast channel, where data written by anyone is seen by everyone else.

unGetChan :: NFData a => Chan a -> a -> IO () Source #

Put a data item back onto a channel, where it will be the next item read.

isEmptyChan :: NFData a => Chan a -> IO Bool Source #

Returns True if the supplied Chan is empty.

Stream interface

getChanContents :: NFData a => Chan a -> IO [a] Source #

Return a lazy list representing the contents of the supplied Chan, much like hGetContents.

writeList2Chan :: NFData a => Chan a -> [a] -> IO () Source #

Write an entire list of items to a Chan.