Skip to content
Snippets Groups Projects
Commit c9604d73 authored by Jens Nolte's avatar Jens Nolte
Browse files

Add writeTMVar shim for old stm version


Co-authored-by: default avatarJan Beinke <git@janbeinke.com>
parent 72d71b72
No related branches found
No related tags found
No related merge requests found
...@@ -73,9 +73,7 @@ module Control.Concurrent.STM.Class ( ...@@ -73,9 +73,7 @@ module Control.Concurrent.STM.Class (
takeTMVar, takeTMVar,
putTMVar, putTMVar,
readTMVar, readTMVar,
#if MIN_VERSION_stm(2, 5, 1)
writeTMVar, writeTMVar,
#endif
tryReadTMVar, tryReadTMVar,
swapTMVar, swapTMVar,
tryTakeTMVar, tryTakeTMVar,
...@@ -421,3 +419,12 @@ $(mconcat <$> (execWriterT do ...@@ -421,3 +419,12 @@ $(mconcat <$> (execWriterT do
'STM.newTBQueueIO 'STM.newTBQueueIO
] ]
)) ))
#if !MIN_VERSION_stm(2, 5, 1)
-- | Non-blocking write of a new value to a 'TMVar'
-- Puts if empty. Replaces if populated.
writeTMVar :: MonadSTM' r t m => STM.TMVar a -> a -> m ()
writeTMVar t new = unsafeLimitSTM $ tryTakeTMVar t >> putTMVar t new
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment