Commit 42ef0845 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan
Browse files

Improve `readChan` documentation:

- Mention that the read end is an `MVar`, so fairness guarantees are

- Mention that it can throw `BlockedIndefinitelyOnMVar` exception.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #5466

Differential Revision:
parent b1acb167
......@@ -100,7 +100,13 @@ writeChan (Chan _ writeVar) val = do
-- completes and before modifyMVar_ installs the new value, it will set the
-- Chan's write end to a filled hole.
-- |Read the next value from the 'Chan'.
-- |Read the next value from the 'Chan'. Blocks when the channel is empty. Since
-- the read end of a channel is an 'MVar', this operation inherits fairness
-- guarantees of 'MVar's (e.g. threads blocked in this operation are woken up in
-- FIFO order).
-- Throws 'BlockedIndefinitelyOnMVar' when the channel is empty and no other
-- thread holds a reference to the channel.
readChan :: Chan a -> IO a
readChan (Chan readVar _) = do
modifyMVarMasked readVar $ \read_end -> do -- Note [modifyMVarMasked]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment