Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is a comment about laziness in tryReadTBQueueDefault correct? #197

Open
amesgen opened this issue Dec 7, 2024 · 0 comments
Open

Is a comment about laziness in tryReadTBQueueDefault correct? #197

amesgen opened this issue Dec 7, 2024 · 0 comments
Labels
question Further information is requested

Comments

@amesgen
Copy link
Member

amesgen commented Dec 7, 2024

While putting #196 together I noticed this comment:

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

Is this actually true for the code here? This doesn't look like a lazy pattern match to me; forcing the first cons of reverse ys will force the linear (in the length of zs) amount of computation as part of the STM transaction AFAICT. If so, it probably makes sense to either fix this (but it isn't high priority as it isn't used by IO) or remove the comment.

Also see the upstream readTBQueue for comparison: https://github.com/haskell/stm/blob/07df1050ab5d45244f718eee8a512bb18e7066f6/Control/Concurrent/STM/TBQueue.hs#L133-L140

@amesgen amesgen added the question Further information is requested label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant