module Effectful.Concurrent.STM
(
Concurrent
, runConcurrent
, STM.STM
, atomically
, STM.retry
, STM.orElse
, STM.check
, STM.throwSTM
, STM.catchSTM
, 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.flushTQueue
, STM.writeTQueue
, STM.unGetTQueue
, STM.isEmptyTQueue
, STM.TBQueue
, STM.newTBQueue
, newTBQueueIO
, STM.readTBQueue
, STM.tryReadTBQueue
, STM.peekTBQueue
, STM.tryPeekTBQueue
, STM.flushTBQueue
, STM.writeTBQueue
, STM.unGetTBQueue
, STM.lengthTBQueue
, STM.isEmptyTBQueue
, STM.isFullTBQueue
) where
import Control.Concurrent.STM (STM, TVar, TMVar, TChan, TQueue, TBQueue)
import qualified Control.Concurrent.STM as STM
import System.Mem.Weak (Weak)
import GHC.Natural (Natural)
import Effectful
import Effectful.Concurrent.Effect
import Effectful.Dispatch.Static
import Effectful.Dispatch.Static.Primitive
atomically :: Concurrent :> es => STM a -> Eff es a
atomically :: forall (es :: [Effect]) a. (Concurrent :> es) => STM a -> Eff es a
atomically = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. STM a -> IO a
STM.atomically
newTVarIO :: Concurrent :> es => a -> Eff es (TVar a)
newTVarIO :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
a -> Eff es (TVar a)
newTVarIO = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> IO (TVar a)
STM.newTVarIO
readTVarIO :: Concurrent :> es => TVar a -> Eff es a
readTVarIO :: forall (es :: [Effect]) a. (Concurrent :> es) => TVar a -> Eff es a
readTVarIO = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. TVar a -> IO a
STM.readTVarIO
registerDelay :: Concurrent :> es => Int -> Eff es (TVar Bool)
registerDelay :: forall (es :: [Effect]).
(Concurrent :> es) =>
Int -> Eff es (TVar Bool)
registerDelay = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (TVar Bool)
STM.registerDelay
mkWeakTVar :: Concurrent :> es => TVar a -> Eff es () -> Eff es (Weak (TVar a))
mkWeakTVar :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
TVar a -> Eff es () -> Eff es (Weak (TVar a))
mkWeakTVar TVar a
var Eff es ()
f = forall (es :: [Effect]) a. (Env es -> IO a) -> Eff es a
unsafeEff forall a b. (a -> b) -> a -> b
$ \Env es
es -> do
forall a. TVar a -> IO () -> IO (Weak (TVar a))
STM.mkWeakTVar TVar a
var forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (es :: [Effect]) a. Eff es a -> Env es -> IO a
unEff Eff es ()
f forall (m :: Type -> Type) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (es :: [Effect]). Env es -> IO (Env es)
cloneEnv Env es
es
newTMVarIO :: Concurrent :> es => a -> Eff es (TMVar a)
newTMVarIO :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
a -> Eff es (TMVar a)
newTMVarIO = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> IO (TMVar a)
STM.newTMVarIO
newEmptyTMVarIO :: Concurrent :> es => Eff es (TMVar a)
newEmptyTMVarIO :: forall (es :: [Effect]) a. (Concurrent :> es) => Eff es (TMVar a)
newEmptyTMVarIO = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall a. IO (TMVar a)
STM.newEmptyTMVarIO
mkWeakTMVar :: Concurrent :> es => TMVar a -> Eff es () -> Eff es (Weak (TMVar a))
mkWeakTMVar :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
TMVar a -> Eff es () -> Eff es (Weak (TMVar a))
mkWeakTMVar TMVar a
var Eff es ()
f = forall (es :: [Effect]) a. (Env es -> IO a) -> Eff es a
unsafeEff forall a b. (a -> b) -> a -> b
$ \Env es
es -> do
forall a. TMVar a -> IO () -> IO (Weak (TMVar a))
STM.mkWeakTMVar TMVar a
var forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (es :: [Effect]) a. Eff es a -> Env es -> IO a
unEff Eff es ()
f forall (m :: Type -> Type) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (es :: [Effect]). Env es -> IO (Env es)
cloneEnv Env es
es
newTChanIO :: Concurrent :> es => Eff es (TChan a)
newTChanIO :: forall (es :: [Effect]) a. (Concurrent :> es) => Eff es (TChan a)
newTChanIO = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall a. IO (TChan a)
STM.newTChanIO
newBroadcastTChanIO :: Concurrent :> es => Eff es (TChan a)
newBroadcastTChanIO :: forall (es :: [Effect]) a. (Concurrent :> es) => Eff es (TChan a)
newBroadcastTChanIO = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall a. IO (TChan a)
STM.newBroadcastTChanIO
newTQueueIO :: Concurrent :> es => Eff es (TQueue a)
newTQueueIO :: forall (es :: [Effect]) a. (Concurrent :> es) => Eff es (TQueue a)
newTQueueIO = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall a. IO (TQueue a)
STM.newTQueueIO
newTBQueueIO :: Concurrent :> es => Natural -> Eff es (TBQueue a)
newTBQueueIO :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
Natural -> Eff es (TBQueue a)
newTBQueueIO = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Natural -> IO (TBQueue a)
STM.newTBQueueIO