Movatterモバイル変換


[0]ホーム

URL:


base-4.12.0.0: Basic libraries

Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilitynon-portable (concurrency)
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Concurrent.Chan

Contents

Description

Unbounded channels.

The channels are implemented withMVars and therefore inherit all the caveats that apply toMVars (possibility of races, deadlocks etc). The stm (software transactional memory) library has a more robust implementation of channels calledTChans.

Synopsis

TheChan type

dataChan aSource#

Chan is an abstract type representing an unbounded FIFO channel.

Instances
Eq (Chan a)Source#

Since: 4.4.0.0

Instance details

Defined inControl.Concurrent.Chan

Methods

(==) ::Chan a ->Chan a ->Bool#

(/=) ::Chan a ->Chan a ->Bool#

Operations

newChan ::IO (Chan a)Source#

Build and returns a new instance ofChan.

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

Write a value to aChan.

readChan ::Chan a ->IO aSource#

Read the next value from theChan. Blocks when the channel is empty. Since the read end of a channel is anMVar, this operation inherits fairness guarantees ofMVars (e.g. threads blocked in this operation are woken up in FIFO order).

ThrowsBlockedIndefinitelyOnMVar when the channel is empty and no other thread holds a reference to the channel.

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

Duplicate aChan: 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.

(Note that a duplicated channel is not equal to its original. So:fmap (c /=) $ dupChan c returnsTrue for allc.)

Stream interface

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

Return a lazy list representing the contents of the suppliedChan, much likehGetContents.

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

Write an entire list of items to aChan.

Produced byHaddock version 2.20.0


[8]ページ先頭

©2009-2025 Movatter.jp