Skip to content

Commit

Permalink
Merge #79
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Jul 21, 2023
2 parents 6e6c830 + 433a81f commit 366560b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Network/HTTP2/Arch/Manager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Network.HTTP2.Arch.Manager (
, deleteMyId
, timeoutKillThread
, timeoutClose
, KilledByHttp2ThreadPoolManager(..)
) where

import Control.Exception
Expand Down Expand Up @@ -124,7 +125,7 @@ del tid set = set'
set' = Set.delete tid set

kill :: Set ThreadId -> IO ()
kill set = traverse_ killThread set
kill set = traverse_ (\tid -> E.throwTo tid KilledByHttp2ThreadPoolManager) set

-- | Killing the IO action of the second argument on timeout.
timeoutKillThread :: Manager -> (T.Handle -> IO ()) -> IO ()
Expand All @@ -138,3 +139,11 @@ timeoutClose :: Manager -> IO () -> IO (IO ())
timeoutClose (Manager _ _ tmgr) closer = do
th <- T.register tmgr closer
return $ T.tickle th

data KilledByHttp2ThreadPoolManager = KilledByHttp2ThreadPoolManager
deriving Show

instance Exception KilledByHttp2ThreadPoolManager where
toException = asyncExceptionToException
fromException = asyncExceptionFromException

7 changes: 5 additions & 2 deletions Network/HTTP2/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ module Network.HTTP2.Internal (
, defaultTrailersMaker
, NextTrailersMaker(..)
, runTrailersMaker
) where
-- * Exceptions
, KilledByHttp2ThreadPoolManager(..)
) where

import Network.HTTP2.Arch.File
import Network.HTTP2.Arch.Types
import Network.HTTP2.Arch.Manager
import Network.HTTP2.Arch.Sender
import Network.HTTP2.Arch.Types

0 comments on commit 366560b

Please sign in to comment.