{-# LANGUAGE RecordWildCards #-}
module Network.HTTP2.Arch.Queue where
import UnliftIO.STM
import Network.HTTP2.Arch.Manager
import Network.HTTP2.Arch.Types
{-# INLINE forkAndEnqueueWhenReady #-}
forkAndEnqueueWhenReady :: IO () -> TQueue (Output Stream) -> Output Stream -> Manager -> IO ()
forkAndEnqueueWhenReady :: IO ()
-> TQueue (Output Stream) -> Output Stream -> Manager -> IO ()
forkAndEnqueueWhenReady IO ()
wait TQueue (Output Stream)
outQ Output Stream
out Manager
mgr =
Manager -> IO () -> IO ()
forkManaged Manager
mgr forall a b. (a -> b) -> a -> b
$ do
IO ()
wait
TQueue (Output Stream) -> Output Stream -> IO ()
enqueueOutput TQueue (Output Stream)
outQ Output Stream
out
{-# INLINE enqueueOutput #-}
enqueueOutput :: TQueue (Output Stream) -> Output Stream -> IO ()
enqueueOutput :: TQueue (Output Stream) -> Output Stream -> IO ()
enqueueOutput TQueue (Output Stream)
outQ Output Stream
out = forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically forall a b. (a -> b) -> a -> b
$ forall a. TQueue a -> a -> STM ()
writeTQueue TQueue (Output Stream)
outQ Output Stream
out
{-# INLINE enqueueControl #-}
enqueueControl :: TQueue Control -> Control -> IO ()
enqueueControl :: TQueue Control -> Control -> IO ()
enqueueControl TQueue Control
ctlQ Control
ctl = forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically forall a b. (a -> b) -> a -> b
$ forall a. TQueue a -> a -> STM ()
writeTQueue TQueue Control
ctlQ Control
ctl