on master help sign in
Revert "Use atomic-primops for Counter"

This reverts commit 0247207811dcc66374199efe5da7ca04a2c34d50.

commitf65706c7065fb13a6a18b9c00497c99db3447ea2 authorMichael Snoyman <michael@snoyman.com> dateFri 3 Oct 2014, 08:28 (12 years ago) parentcdaf0b3
2 files changed+6−8
warp/Network/Wai/Handler/Warp/Counter.hs+6−6 warp/warp.cabal−2
warp/Network/Wai/Handler/Warp/Counter.hs+6−6
@@ -6,19 +6,19 @@ module Network.Wai.Handler.Warp.Counter (
66 , decrease
77 ) where
88
9−import qualified Data.Atomics.Counter.Unboxed as C
9+import Network.Wai.Handler.Warp.IORef
1010import Control.Applicative ((<$>))
1111
12−newtype Counter = Counter C.AtomicCounter
12+newtype Counter = Counter (IORef Int)
1313
1414newCounter :: IO Counter
15−newCounter = Counter <$> C.newCounter 0
15+newCounter = Counter <$> newIORef 0
1616
1717isZero :: Counter -> IO Bool
18−isZero (Counter ref) = (== 0) <$> C.readCounter ref
18+isZero (Counter ref) = (== 0) <$> readIORef ref
1919
2020increase :: Counter -> IO ()
21−increase (Counter ref) = C.incrCounter_ 1 ref
21+increase (Counter ref) = atomicModifyIORef' ref $ \x -> (x + 1, ())
2222
2323decrease :: Counter -> IO ()
24−decrease (Counter ref) = C.incrCounter_ (-1) ref
24+decrease (Counter ref) = atomicModifyIORef' ref $ \x -> (x - 1, ())
warp/warp.cabal−2
@@ -52,7 +52,6 @@ Library
5252 , wai >= 3.0 && < 3.1
5353 , text
5454 , streaming-commons >= 0.1.2
55− , atomic-primops >= 0.6
5655 if flag(network-bytestring)
5756 Build-Depends: network >= 2.2.1.5 && < 2.2.3
5857 , network-bytestring >= 0.1.3 && < 0.1.4
@@ -144,7 +143,6 @@ Test-Suite spec
144143 , text
145144 , streaming-commons >= 0.1.1
146145 , async
147− , atomic-primops
148146
149147 if (os(linux) || os(freebsd) || os(darwin)) && flag(allow-sendfilefd)
150148 Cpp-Options: -DSENDFILEFD