module UnliftIO.MVar
( MVar
, newEmptyMVar
, newMVar
, takeMVar
, putMVar
, readMVar
, swapMVar
, tryTakeMVar
, tryPutMVar
, isEmptyMVar
, withMVar
, withMVarMasked
, modifyMVar
, modifyMVar_
, modifyMVarMasked
, modifyMVarMasked_
, tryReadMVar
, mkWeakMVar
) where
import System.Mem.Weak (Weak)
import Control.Concurrent.MVar (MVar)
import Control.Monad.IO.Unlift
import qualified Control.Concurrent.MVar as M
newEmptyMVar :: MonadIO m => m (MVar a)
newEmptyMVar = liftIO M.newEmptyMVar
newMVar :: MonadIO m => a -> m (MVar a)
newMVar = liftIO . M.newMVar
takeMVar :: MonadIO m => MVar a -> m a
takeMVar = liftIO . M.takeMVar
putMVar :: MonadIO m => MVar a -> a -> m ()
putMVar var = liftIO . M.putMVar var
readMVar :: MonadIO m => MVar a -> m a
readMVar = liftIO . M.readMVar
swapMVar :: MonadIO m => MVar a -> a -> m a
swapMVar var = liftIO . M.swapMVar var
tryTakeMVar :: MonadIO m => MVar a -> m (Maybe a)
tryTakeMVar = liftIO . M.tryTakeMVar
tryPutMVar :: MonadIO m => MVar a -> a -> m Bool
tryPutMVar var = liftIO . M.tryPutMVar var
isEmptyMVar :: MonadIO m => MVar a -> m Bool
isEmptyMVar = liftIO . M.isEmptyMVar
tryReadMVar :: MonadIO m => MVar a -> m (Maybe a)
tryReadMVar = liftIO . M.tryReadMVar
withMVar :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b
withMVar var f = withRunInIO $ \run -> M.withMVar var (run . f)
withMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b
withMVarMasked var f = withRunInIO $ \run -> M.withMVarMasked var (run . f)
modifyMVar_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m ()
modifyMVar_ var f = withRunInIO $ \run -> M.modifyMVar_ var (run . f)
modifyMVar :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b
modifyMVar var f = withRunInIO $ \run -> M.modifyMVar var (run . f)
modifyMVarMasked_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m ()
modifyMVarMasked_ var f = withRunInIO $ \run -> M.modifyMVarMasked_ var (run . f)
modifyMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b
modifyMVarMasked var f = withRunInIO $ \run -> M.modifyMVarMasked var (run . f)
mkWeakMVar :: MonadUnliftIO m => MVar a -> m () -> m (Weak (MVar a))
mkWeakMVar var f = withRunInIO $ \run -> M.mkWeakMVar var (run f)