Skip to content

Commit

Permalink
Merge pull request #13 from haskell-servant/manager-ioref
Browse files Browse the repository at this point in the history
Use an `IORef` rather than a `MVar`.
  • Loading branch information
jkarni committed Mar 8, 2015
2 parents 1af0d7b + 449b375 commit 83aff14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
---
* Support content-type aware combinators and `Accept`/`Content-type` headers
* Added a lot of tests
* Support multiple concurrent threads

0.2.2
-----
* Add TLS support
* Add matrix parameter support
* Add matrix parameter support
10 changes: 4 additions & 6 deletions src/Servant/Common/Req.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
module Servant.Common.Req where

import Control.Applicative
import Control.Concurrent
import Control.Exception
import Control.Monad
import Control.Monad.Catch (MonadThrow)
import Control.Monad.IO.Class
import Control.Monad.Trans.Either
import Data.ByteString.Lazy hiding (pack, filter, map, null)
import Data.IORef
import Data.String
import Data.String.Conversions
import Data.Proxy
Expand Down Expand Up @@ -98,13 +98,11 @@ reqToRequest req (BaseUrl reqScheme reqHost reqPort) =
-- * performing requests

{-# NOINLINE __manager #-}
__manager :: MVar Manager
__manager = unsafePerformIO (newManager tlsManagerSettings >>= newMVar)
__manager :: IORef Manager
__manager = unsafePerformIO (newManager tlsManagerSettings >>= newIORef)

__withGlobalManager :: (Manager -> IO a) -> IO a
__withGlobalManager action = modifyMVar __manager $ \ manager -> do
result <- action manager
return (manager, result)
__withGlobalManager action = readIORef __manager >>= action


displayHttpRequest :: Method -> String
Expand Down

0 comments on commit 83aff14

Please sign in to comment.