{-# LANGUAGE RecordWildCards #-}

module Network.HTTP2.H2.Queue where

import Control.Concurrent.STM

import Network.HTTP2.H2.Types

{-# INLINE enqueueOutput #-}
enqueueOutput :: TQueue Output -> Output -> IO ()
enqueueOutput :: TQueue Output -> Output -> IO ()
enqueueOutput TQueue Output
outQ Output
out = STM () -> IO ()
forall a. STM a -> IO a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ TQueue Output -> Output -> STM ()
forall a. TQueue a -> a -> STM ()
writeTQueue TQueue Output
outQ Output
out

{-# INLINE enqueueOutputSTM #-}
enqueueOutputSTM :: TQueue Output -> Output -> STM ()
enqueueOutputSTM :: TQueue Output -> Output -> STM ()
enqueueOutputSTM TQueue Output
outQ Output
out = TQueue Output -> Output -> STM ()
forall a. TQueue a -> a -> STM ()
writeTQueue TQueue Output
outQ Output
out

{-# INLINE enqueueControl #-}
enqueueControl :: TQueue Control -> Control -> IO ()
enqueueControl :: TQueue Control -> Control -> IO ()
enqueueControl TQueue Control
ctlQ Control
ctl = STM () -> IO ()
forall a. STM a -> IO 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

----------------------------------------------------------------