{-# LANGUAGE CPP #-}
module UnliftIO.STM
(
STM.STM
, atomically
, retrySTM
, checkSTM
, STM.TVar
, newTVarIO
, readTVarIO
, STM.newTVar
, STM.readTVar
, STM.writeTVar
, STM.modifyTVar
, STM.modifyTVar'
, STM.swapTVar
, registerDelay
, mkWeakTVar
, STM.TMVar
, STM.newTMVar
, STM.newEmptyTMVar
, newTMVarIO
, newEmptyTMVarIO
, STM.takeTMVar
, STM.putTMVar
, STM.readTMVar
, STM.tryReadTMVar
, STM.swapTMVar
, STM.tryTakeTMVar
, STM.tryPutTMVar
, STM.isEmptyTMVar
, mkWeakTMVar
, STM.TChan
, STM.newTChan
, newTChanIO
, STM.newBroadcastTChan
, newBroadcastTChanIO
, STM.dupTChan
, STM.cloneTChan
, STM.readTChan
, STM.tryReadTChan
, STM.peekTChan
, STM.tryPeekTChan
, STM.writeTChan
, STM.unGetTChan
, STM.isEmptyTChan
, STM.TQueue
, STM.newTQueue
, newTQueueIO
, STM.readTQueue
, STM.tryReadTQueue
, STM.peekTQueue
, STM.tryPeekTQueue
, STM.writeTQueue
, STM.unGetTQueue
, STM.isEmptyTQueue
, STM.TBQueue
, STM.newTBQueue
, newTBQueueIO
, STM.readTBQueue
, STM.tryReadTBQueue
, STM.peekTBQueue
, STM.tryPeekTBQueue
, STM.writeTBQueue
, STM.unGetTBQueue
, STM.isEmptyTBQueue
, STM.isFullTBQueue
) where
import Control.Concurrent.STM (STM, TVar, TMVar, TChan, TQueue, TBQueue)
import qualified Control.Concurrent.STM as STM
import Control.Monad.IO.Unlift
import System.Mem.Weak (Weak)
#if MIN_VERSION_stm(2, 5, 0)
import GHC.Natural (Natural)
#endif
atomically :: MonadIO m => STM a -> m a
atomically = liftIO . STM.atomically
retrySTM :: STM a
retrySTM = STM.retry
checkSTM :: Bool -> STM ()
checkSTM = STM.check
newTVarIO :: MonadIO m => a -> m (TVar a)
newTVarIO = liftIO . STM.newTVarIO
readTVarIO :: MonadIO m => TVar a -> m a
readTVarIO = liftIO . STM.readTVarIO
registerDelay :: MonadIO m => Int -> m (TVar Bool)
registerDelay = liftIO . STM.registerDelay
mkWeakTVar :: MonadUnliftIO m => TVar a -> m () -> m (Weak (TVar a))
mkWeakTVar var final = withRunInIO $ \run -> STM.mkWeakTVar var (run final)
newTMVarIO :: MonadIO m => a -> m (TMVar a)
newTMVarIO = liftIO . STM.newTMVarIO
newEmptyTMVarIO :: MonadIO m => m (TMVar a)
newEmptyTMVarIO = liftIO STM.newEmptyTMVarIO
mkWeakTMVar :: MonadUnliftIO m => TMVar a -> m () -> m (Weak (TMVar a))
mkWeakTMVar var final = withRunInIO $ \run -> STM.mkWeakTMVar var (run final)
newTChanIO :: MonadIO m => m (TChan a)
newTChanIO = liftIO STM.newTChanIO
newBroadcastTChanIO :: MonadIO m => m (TChan a)
newBroadcastTChanIO = liftIO STM.newBroadcastTChanIO
newTQueueIO :: MonadIO m => m (TQueue a)
newTQueueIO = liftIO STM.newTQueueIO
#if MIN_VERSION_stm(2, 5, 0)
newTBQueueIO :: MonadIO m => Natural -> m (TBQueue a)
#else
newTBQueueIO :: MonadIO m => Int -> m (TBQueue a)
#endif
newTBQueueIO = liftIO . STM.newTBQueueIO