avoid fromIntegral overhead
This commit is contained in:
parent
4e0a678a99
commit
99a1287f4f
2 changed files with 4 additions and 4 deletions
|
@ -75,4 +75,4 @@ inDb h k = H.runDb h $ do
|
||||||
- fsck left off, and making too many commits which slows down the fsck
|
- fsck left off, and making too many commits which slows down the fsck
|
||||||
- of lots of small or not present files. -}
|
- of lots of small or not present files. -}
|
||||||
commitPolicy :: H.CommitPolicy
|
commitPolicy :: H.CommitPolicy
|
||||||
commitPolicy = H.CommitAfterSeconds 60
|
commitPolicy = H.CommitAfter (fromIntegral (60 :: Int))
|
||||||
|
|
|
@ -67,7 +67,7 @@ workerThread db jobs = go
|
||||||
runDb :: DbHandle -> SqlPersistM a -> IO a
|
runDb :: DbHandle -> SqlPersistM a -> IO a
|
||||||
runDb h = runDb' h CommitManually
|
runDb h = runDb' h CommitManually
|
||||||
|
|
||||||
data CommitPolicy = CommitManually | CommitAfterSeconds Int
|
data CommitPolicy = CommitManually | CommitAfter NominalDiffTime
|
||||||
|
|
||||||
runDb' :: DbHandle -> CommitPolicy -> SqlPersistM a -> IO a
|
runDb' :: DbHandle -> CommitPolicy -> SqlPersistM a -> IO a
|
||||||
runDb' h@(DbHandle _ jobs t) pol a = do
|
runDb' h@(DbHandle _ jobs t) pol a = do
|
||||||
|
@ -76,11 +76,11 @@ runDb' h@(DbHandle _ jobs t) pol a = do
|
||||||
r <- either throwIO return =<< takeMVar res
|
r <- either throwIO return =<< takeMVar res
|
||||||
case pol of
|
case pol of
|
||||||
CommitManually -> return ()
|
CommitManually -> return ()
|
||||||
CommitAfterSeconds n -> do
|
CommitAfter n -> do
|
||||||
now <- getCurrentTime
|
now <- getCurrentTime
|
||||||
prev <- takeMVar t
|
prev <- takeMVar t
|
||||||
putMVar t now
|
putMVar t now
|
||||||
when (diffUTCTime now prev > fromIntegral n) $
|
when (diffUTCTime now prev > n) $
|
||||||
commitDb h
|
commitDb h
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue