We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5ea70d4 + a77aae7 commit 622f386Copy full SHA for 622f386
Control/Concurrent/STM/TQueue.hs
@@ -47,7 +47,7 @@ module Control.Concurrent.STM.TQueue (
47
) where
48
49
import GHC.Conc
50
-
+import Control.Monad (unless)
51
import Data.Typeable (Typeable)
52
53
-- | 'TQueue' is an abstract type representing an unbounded FIFO channel.
@@ -115,8 +115,8 @@ flushTQueue :: TQueue a -> STM [a]
115
flushTQueue (TQueue read write) = do
116
xs <- readTVar read
117
ys <- readTVar write
118
- writeTVar read []
119
- writeTVar write []
+ unless (null xs) $ writeTVar read []
+ unless (null ys) $ writeTVar write []
120
return (xs ++ reverse ys)
121
122
-- | Get the next value from the @TQueue@ without removing it,
0 commit comments