{-# LANGUAGE RecordWildCards #-}
module Network.HTTP2.H2.Queue where
import UnliftIO.STM
import Network.HTTP2.H2.Manager
import Network.HTTP2.H2.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 (IO () -> IO ()) -> IO () -> IO ()
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 = STM () -> IO ()
forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ TQueue (Output Stream) -> Output Stream -> STM ()
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 = STM () -> IO ()
forall (m :: * -> *) a. MonadIO m => STM a -> m a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ TQueue Control -> Control -> STM ()
forall a. TQueue a -> a -> STM ()
writeTQueue TQueue Control
ctlQ Control
ctl