Skip to content

Is a comment about laziness in tryReadTBQueueDefault correct? #197

Open
@amesgen

Description

@amesgen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions