Skip to content

Commit

Permalink
better type signature for client's aux
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Nov 18, 2023
1 parent e034b37 commit 823436f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions Network/HTTP2/Client/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ run cconf@ClientConfig{..} conf client = do
(ctx, mgr) <- setup cconf conf
runH2 conf ctx mgr $ runClient ctx mgr
where
serverMaxStreams ctx = maxConcurrentStreams <$> readIORef (peerSettings ctx)
possibleClientStream ctx = do
mx <- serverMaxStreams ctx
serverMaxStreams ctx = do
mx <- maxConcurrentStreams <$> readIORef (peerSettings ctx)
case mx of
Nothing -> return Nothing
Just x -> do
n <- oddConc <$> readTVarIO (oddStreamTable ctx)
return $ Just (x - n)
Nothing -> return maxBound
Just x -> return x
possibleClientStream ctx = do
x <- serverMaxStreams ctx
n <- oddConc <$> readTVarIO (oddStreamTable ctx)
return (x - n)
aux ctx =
Aux
{ auxPossibleClientStreams = possibleClientStream ctx
Expand Down
8 changes: 4 additions & 4 deletions Network/HTTP2/Client/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ newtype Response = Response InpObj deriving (Show)

-- | Additional information.
data Aux = Aux
{ auxPossibleClientStreams :: IO (Maybe Int)
{ auxPossibleClientStreams :: IO Int
-- ^ How many streams can be created without blocking.
-- 'Nothing' means infinity.
, auxServerMaxStreams :: IO (Maybe Int)
, auxServerMaxStreams :: IO Int
-- ^ Getting server's SETTINGS_MAX_CONCURRENT_STREAMS.
-- 'Nothing' means no limit.
-- If the server does not inform it,
-- 'concurrentStreams' is used.
}

0 comments on commit 823436f

Please sign in to comment.