Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use generic ThreadKilled #79

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading