-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compatibility with resource-pool < 0.3
- Loading branch information
Showing
3 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{-# LANGUAGE CPP #-} | ||
|
||
module Data.Pool.Compat | ||
( module Data.Pool | ||
, createPool | ||
) where | ||
|
||
import Prelude | ||
|
||
import Data.Pool hiding (createPool) | ||
#if MIN_VERSION_resource_pool(0,3,0) | ||
#else | ||
import Control.Concurrent (getNumCapabilities) | ||
import qualified Data.Pool as Pool | ||
#endif | ||
|
||
createPool | ||
:: IO a | ||
-> (a -> IO ()) | ||
-> Double | ||
-> Int | ||
-> IO (Pool a) | ||
createPool create destroy timeout size = do | ||
#if MIN_VERSION_resource_pool(0,3,0) | ||
newPool $ defaultPoolConfig create destroy timeout size | ||
#else | ||
-- Re-implement instead of using the deprecated compatibility function, so | ||
-- that we can get a consistent numStripes and size behavior. | ||
numStripes <- getNumCapabilities | ||
Pool.createPool create destroy numStripes (realToFrac timeout) size | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters