Skip to content

Add mkWeakTMVar to Control.Concurrent.STM.TMVar

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.

Trac metadata
Trac field Value
Version 7.8.2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries (other)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information