[commit: stm] master: Replaced talk of "blocking" with "retrying" (c820b8e)
Simon Marlow
marlowsd at gmail.com
Mon Apr 11 12:42:57 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/stm
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/c820b8e6500591df1d17c527874f91e9a314366b
>---------------------------------------------------------------
commit c820b8e6500591df1d17c527874f91e9a314366b
Author: Simon Marlow <marlowsd at gmail.com>
Date: Mon Apr 11 11:06:37 2011 +0100
Replaced talk of "blocking" with "retrying"
>---------------------------------------------------------------
Control/Concurrent/STM/TChan.hs | 10 ++++++----
Control/Concurrent/STM/TMVar.hs | 3 ++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Control/Concurrent/STM/TChan.hs b/Control/Concurrent/STM/TChan.hs
index cdd62f9..18aa9f9 100644
--- a/Control/Concurrent/STM/TChan.hs
+++ b/Control/Concurrent/STM/TChan.hs
@@ -82,7 +82,8 @@ readTChan (TChan read _write) = do
writeTVar read tail
return a
--- | Non-blocking version of 'readTChan'.
+-- | A version of 'readTChan' which does not retry. Instead it
+-- returns @Nothing@ if no value is available.
tryReadTChan :: TChan a -> STM (Maybe a)
tryReadTChan (TChan read _write) = do
listhead <- readTVar read
@@ -93,8 +94,8 @@ tryReadTChan (TChan read _write) = do
writeTVar read tl
return (Just a)
--- | Get the next value from the 'TChan' without removing it,
--- blocking if the channel is empty.
+-- | Get the next value from the @TChan@ without removing it,
+-- retrying if the channel is empty.
peekTChan :: TChan a -> STM a
peekTChan (TChan read _write) = do
listhead <- readTVar read
@@ -103,7 +104,8 @@ peekTChan (TChan read _write) = do
TNil -> retry
TCons a _ -> return a
--- | Non-blocking version of 'peekTChan'.
+-- | A version of 'peekTChan' which does not retry. Instead it
+-- returns @Nothing@ if no value is available.
tryPeekTChan :: TChan a -> STM (Maybe a)
tryPeekTChan (TChan read _write) = do
listhead <- readTVar read
diff --git a/Control/Concurrent/STM/TMVar.hs b/Control/Concurrent/STM/TMVar.hs
index 05c83f6..653736f 100644
--- a/Control/Concurrent/STM/TMVar.hs
+++ b/Control/Concurrent/STM/TMVar.hs
@@ -126,7 +126,8 @@ readTMVar (TMVar t) = do
Nothing -> retry
Just a -> return a
--- | Non-blocking version of 'readTMVar'.
+-- | A version of 'readTMVar' which does not retry. Instead it
+-- returns @Nothing@ if no value is available.
tryReadTMVar :: TMVar a -> STM (Maybe a)
tryReadTMVar (TMVar t) = readTVar t
More information about the Cvs-libraries
mailing list