Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions io-classes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Revsion history of io-classes

### next version

### Breaking changes

### Non-breaking changes

* Improved performance of `tryReadTBQueueDefault`.

### 1.8.0.1

* Added support for `ghc-9.2`.
Expand Down
11 changes: 7 additions & 4 deletions io-classes/src/Control/Monad/Class/MonadSTM/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,15 @@ tryReadTBQueueDefault (TBQueue rsize read _wsize write _size) = do
return (Just x)
[] -> do
ys <- readTVar write
case reverse ys of
case ys of
[] -> return Nothing
_ -> do
-- NB. lazy: we want the transaction to be
-- short, otherwise it will conflict
let ~(z,zs) = case reverse ys of
z':zs' -> (z',zs')
_ -> error "tryReadTBQueueDefault: impossible"

-- NB. lazy: we want the transaction to be
-- short, otherwise it will conflict
(z:zs) -> do
writeTVar write []
writeTVar read zs
return (Just z)
Expand Down
2 changes: 2 additions & 0 deletions io-sim/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### Non-breaking changes

* Removed a misleading internal comment.

### 1.8.0.1

* Added support for `ghc-9.2`.
Expand Down
2 changes: 0 additions & 2 deletions io-sim/src/Control/Monad/IOSim/STM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ tryReadTBQueueDefault (TBQueue queue _size) = do
case reverse ys of
[] -> return Nothing

-- NB. lazy: we want the transaction to be
-- short, otherwise it will conflict
(z:zs) -> do
writeTVar queue $! (zs, r', [], w)
return (Just z)
Expand Down
Loading