@@ -6,19 +6,19 @@ module Network.Wai.Handler.Warp.Counter (
9−import qualified Data.Atomics.Counter.Unboxed as C
9+import Network.Wai.Handler.Warp.IORef
10import Control.Applicative ((<$>))
10import Control.Applicative ((<$>))
12−newtype Counter = Counter C.AtomicCounter
12+newtype Counter = Counter (IORef Int)
14newCounter :: IO Counter
14newCounter :: IO Counter
15−newCounter = Counter <$> C.newCounter 0
15+newCounter = Counter <$> newIORef 0
17isZero :: Counter -> IO Bool
17isZero :: Counter -> IO Bool
18−isZero (Counter ref) = (== 0) <$> C.readCounter ref
18+isZero (Counter ref) = (== 0) <$> readIORef ref
20increase :: Counter -> IO ()
20increase :: Counter -> IO ()
21−increase (Counter ref) = C.incrCounter_ 1 ref
21+increase (Counter ref) = atomicModifyIORef' ref $ \x -> (x + 1, ())
23decrease :: Counter -> IO ()
23decrease :: Counter -> IO ()
24−decrease (Counter ref) = C.incrCounter_ (-1) ref
24+decrease (Counter ref) = atomicModifyIORef' ref $ \x -> (x - 1, ())