Merge pull request #13 from haskell-servant/manager-ioref
Use an `IORef` rather than a `MVar`.
This commit is contained in:
commit
83aff1495b
2 changed files with 6 additions and 7 deletions
|
@ -2,8 +2,9 @@
|
||||||
---
|
---
|
||||||
* Support content-type aware combinators and `Accept`/`Content-type` headers
|
* Support content-type aware combinators and `Accept`/`Content-type` headers
|
||||||
* Added a lot of tests
|
* Added a lot of tests
|
||||||
|
* Support multiple concurrent threads
|
||||||
|
|
||||||
0.2.2
|
0.2.2
|
||||||
-----
|
-----
|
||||||
* Add TLS support
|
* Add TLS support
|
||||||
* Add matrix parameter support
|
* Add matrix parameter support
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
module Servant.Common.Req where
|
module Servant.Common.Req where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Concurrent
|
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Monad.Catch (MonadThrow)
|
import Control.Monad.Catch (MonadThrow)
|
||||||
import Control.Monad.IO.Class
|
import Control.Monad.IO.Class
|
||||||
import Control.Monad.Trans.Either
|
import Control.Monad.Trans.Either
|
||||||
import Data.ByteString.Lazy hiding (pack, filter, map, null)
|
import Data.ByteString.Lazy hiding (pack, filter, map, null)
|
||||||
|
import Data.IORef
|
||||||
import Data.String
|
import Data.String
|
||||||
import Data.String.Conversions
|
import Data.String.Conversions
|
||||||
import Data.Proxy
|
import Data.Proxy
|
||||||
|
@ -98,13 +98,11 @@ reqToRequest req (BaseUrl reqScheme reqHost reqPort) =
|
||||||
-- * performing requests
|
-- * performing requests
|
||||||
|
|
||||||
{-# NOINLINE __manager #-}
|
{-# NOINLINE __manager #-}
|
||||||
__manager :: MVar Manager
|
__manager :: IORef Manager
|
||||||
__manager = unsafePerformIO (newManager tlsManagerSettings >>= newMVar)
|
__manager = unsafePerformIO (newManager tlsManagerSettings >>= newIORef)
|
||||||
|
|
||||||
__withGlobalManager :: (Manager -> IO a) -> IO a
|
__withGlobalManager :: (Manager -> IO a) -> IO a
|
||||||
__withGlobalManager action = modifyMVar __manager $ \ manager -> do
|
__withGlobalManager action = readIORef __manager >>= action
|
||||||
result <- action manager
|
|
||||||
return (manager, result)
|
|
||||||
|
|
||||||
|
|
||||||
displayHttpRequest :: Method -> String
|
displayHttpRequest :: Method -> String
|
||||||
|
|
Loading…
Add table
Reference in a new issue