@@ -1,10 +1,11 @@
1{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, ViewPatterns #-}
1{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, ViewPatterns #-}
2−{-# LANGUAGE PatternGuards #-}
2+{-# LANGUAGE PatternGuards, RankNTypes #-}
4module Network.Wai.Handler.Warp.Settings where
4module Network.Wai.Handler.Warp.Settings where
6import Control.Exception
6import Control.Exception
7−import Control.Monad (when)
7+import Control.Monad (when, void)
8+import Control.Concurrent (forkIOWithUnmask)
8import qualified Data.Text as T
9import qualified Data.Text as T
9import qualified Data.Text.IO as TIO
10import qualified Data.Text.IO as TIO
10import Data.Streaming.Network (HostPreference)
11import Data.Streaming.Network (HostPreference)
@@ -52,6 +53,17 @@ data Settings = Settings
52 -- Default: do nothing.
53 -- Default: do nothing.
54 -- Since 1.3.6
55 -- Since 1.3.6
57+ , settingsFork :: ((forall a. IO a -> IO a) -> IO ()) -> IO ()
58+ -- ^ Code to fork a new thread to accept a connection.
60+ -- This may be useful if you need OS bound threads, or if
61+ -- you wish to develop an alternative threading model.
63+ -- Default: void . forkIOWithUnmask
55 , settingsNoParsePath :: Bool
67 , settingsNoParsePath :: Bool
56 -- ^ Perform no parsing on the rawPathInfo.
68 -- ^ Perform no parsing on the rawPathInfo.
@@ -85,6 +97,7 @@ defaultSettings = Settings
85 , settingsManager = Nothing
97 , settingsManager = Nothing
86 , settingsFdCacheDuration = 10
98 , settingsFdCacheDuration = 10
87 , settingsBeforeMainLoop = return ()
99 , settingsBeforeMainLoop = return ()
100+ , settingsFork = void . forkIOWithUnmask
88 , settingsNoParsePath = False
101 , settingsNoParsePath = False
89 , settingsInstallShutdownHandler = const $ return ()
102 , settingsInstallShutdownHandler = const $ return ()
90 , settingsServerName = S8.pack $ "Warp/" ++ showVersion Paths_warp.version
103 , settingsServerName = S8.pack $ "Warp/" ++ showVersion Paths_warp.version