[GHC] #9169: Add mkWeakTMVar to Control.Concurrent.STM.TMVar
GHC
ghc-devs at haskell.org
Wed Jun 4 23:15:43 UTC 2014
#9169: Add mkWeakTMVar to Control.Concurrent.STM.TMVar
-------------------------------------+-------------------------------------
Reporter: basvandijk | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: libraries (other) | Version: 7.8.2
Keywords: stm | Operating System: Unknown/Multiple
Architecture: Unknown/Multiple | Type of failure: None/Unknown
Difficulty: Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9169>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list