on master help sign in
Use an `IORef` rather than a `MVar`.

The job of a manager is to synchronize threads, so it is not necessary to block.

commitaeb1136658a186537f995a78fa3bf311d149087a authorTimo von Holtz <tvh@anchor.com.au> dateThu 5 Mar 2015, 09:49 (12 years ago) parent1af0d7b
1 file changed+4−6
src/Servant/Common/Req.hs+4−6
src/Servant/Common/Req.hs+4−6
@@ -3,13 +3,13 @@
33module Servant.Common.Req where
44
55import Control.Applicative
6−import Control.Concurrent
76import Control.Exception
87import Control.Monad
98import Control.Monad.Catch (MonadThrow)
109import Control.Monad.IO.Class
1110import Control.Monad.Trans.Either
1211import Data.ByteString.Lazy hiding (pack, filter, map, null)
12+import Data.IORef
1313import Data.String
1414import Data.String.Conversions
1515import Data.Proxy
@@ -98,13 +98,11 @@ reqToRequest req (BaseUrl reqScheme reqHost reqPort) =
9898-- * performing requests
9999
100100{-# NOINLINE __manager #-}
101−__manager :: MVar Manager
102−__manager = unsafePerformIO (newManager tlsManagerSettings >>= newMVar)
101+__manager :: IORef Manager
102+__manager = unsafePerformIO (newManager tlsManagerSettings >>= newIORef)
103103
104104__withGlobalManager :: (Manager -> IO a) -> IO a
105−__withGlobalManager action = modifyMVar __manager $ \ manager -> do
106− result <- action manager
107− return (manager, result)
105+__withGlobalManager action = readIORef __manager >>= action
108106
109107
110108displayHttpRequest :: Method -> String