Closed ch1bo closed 8 months ago
Describe the bug flushTQueue in IOSim s does not empty the queue, while it does in IO
flushTQueue
IOSim s
IO
To Reproduce
Execute this program:
#!/usr/bin/env cabal {- cabal: build-depends: base, io-sim ^>= 1.3, io-classes ^>= 1.3 -} import Control.Concurrent.Class.MonadSTM import Control.Exception (assert) import Control.Monad (unless) import Control.Monad.IOSim main :: IO () main = do emptyInIO <- emptyQueueAfterFlush unless emptyInIO $ error "queue not emptied from IO" let emptyInIOSim = runSimOrThrow emptyQueueAfterFlush unless emptyInIOSim $ error "queue not emptied from IOSim" emptyQueueAfterFlush :: MonadSTM m => m Bool emptyQueueAfterFlush = do q <- newTQueueIO atomically $ do writeTQueue q 1 _ <- flushTQueue q isEmptyTQueue q
Expected behaviour Same semantics of STM in IO and IOSim
STM
IOSim
Additional context The flushQueueDefault looks wrong when compared with the one of io-classes and the real one from stm
flushQueueDefault
Describe the bug
flushTQueue
inIOSim s
does not empty the queue, while it does inIO
To Reproduce
Execute this program:
Expected behaviour Same semantics of
STM
inIO
andIOSim
Additional context The
flushQueueDefault
looks wrong when compared with the one of io-classes and the real one from stm