Opened 3 years ago

Closed 2 years ago

#9169 closed feature request (fixed)

Add mkWeakTMVar to Control.Concurrent.STM.TMVar

Reported by: basvandijk Owned by: thoughtpolice
Priority: normal Milestone: 7.10.1
Component: Core Libraries Version: 7.8.2
Keywords: stm Cc: core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I just needed a Weak pointer to a TMVar:

-- | Make a 'Weak' pointer to a 'TMVar', using the second argument as
-- a finalizer to run when 'TMVar' is garbage-collected.
mkWeakTMVar :: TMVar a -> IO () -> IO (Weak (TMVar a))
mkWeakTMVar tmv@(TMVar (TVar t#)) f = IO $ \s ->
    case mkWeak# t# tmv f s of (# s1, w #) -> (# s1, Weak w #)

It might make sense to add a similar function for TSem as well.

Attachments (1)

0001-Add-mkWeakTMVar-to-Control.Concurrent.STM.TMVar.patch (2.7 KB) - added by basvandijk 3 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 3 years ago by Austin Seipp <austin@…>

In b0316cdb10fbd9eaca7ede28c7bb3eb19f7766bf/ghc:

reading/writing blocking FDs over FD_SETSIZE is broken (Partially Trac #9169)

libraries/base/cbits/inputReady.c had no limits on file descriptors.
Add a limit as non-threaded RTS does.

Signed-off-by: Sergei Trofimovich <>

Test Plan: none

Reviewers: austin, simonmar

Reviewed By: austin, simonmar

Subscribers: simonmar, relrod, carter

Differential Revision:

comment:2 Changed 3 years ago by thoughtpolice

Status: newpatch

Sorry, this commit had the wrong trac number, it seems!

comment:3 Changed 3 years ago by thoughtpolice

Milestone: 7.10.1

comment:4 Changed 3 years ago by thoughtpolice

Status: patchupstream

comment:5 Changed 2 years ago by thoughtpolice

Component: libraries (other)Core Libraries

Moving over to new owning component 'Core Libraries'.

comment:6 Changed 2 years ago by simonmar

Cc: core-libraries-committee@… added
Owner: set to thoughtpolice

Patch looks fine.

comment:7 Changed 2 years ago by Austin Seipp <austin@…>

In 8afdf274194e77e85e6a08dc4963022c56fc29d8/ghc:

stm: update submodule for #9169 addition

Signed-off-by: Austin Seipp <>

comment:8 Changed 2 years ago by thoughtpolice

Resolution: fixed
Status: upstreamclosed

Merged, thanks!

Note: See TracTickets for help on using tickets.