factor out Utility.MonotonicClock
This commit is contained in:
parent
543c610a31
commit
5b6150e5d5
5 changed files with 30 additions and 15 deletions
13
P2P/IO.hs
13
P2P/IO.hs
|
@ -25,7 +25,6 @@ module P2P.IO
|
|||
, describeProtoFailure
|
||||
, runNetProto
|
||||
, runNet
|
||||
, getMonotonicTimestampIO
|
||||
) where
|
||||
|
||||
import Common
|
||||
|
@ -39,6 +38,7 @@ import Utility.Metered
|
|||
import Utility.Tor
|
||||
import Utility.FileMode
|
||||
import Utility.Debug
|
||||
import Utility.MonotonicClock
|
||||
import Types.UUID
|
||||
import Annex.ChangedRefs
|
||||
import qualified Utility.RawFilePath as R
|
||||
|
@ -54,11 +54,6 @@ import qualified Data.ByteString as B
|
|||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Network.Socket as S
|
||||
import System.PosixCompat.Files (groupReadMode, groupWriteMode, otherReadMode, otherWriteMode)
|
||||
#if MIN_VERSION_clock(0,3,0)
|
||||
import qualified System.Clock as Clock
|
||||
#else
|
||||
import qualified System.Posix.Clock as Clock
|
||||
#endif
|
||||
|
||||
-- Type of interpreters of the Proto free monad.
|
||||
type RunProto m = forall a. Proto a -> m (Either ProtoFailure a)
|
||||
|
@ -289,7 +284,7 @@ runNet runst conn runner f = case f of
|
|||
GetProtocolVersion next ->
|
||||
liftIO (readTVarIO versiontvar) >>= runner . next
|
||||
GetMonotonicTimestamp next ->
|
||||
liftIO getMonotonicTimestampIO >>= runner . next
|
||||
liftIO currentMonotonicTimestamp >>= runner . next
|
||||
where
|
||||
-- This is only used for running Net actions when relaying,
|
||||
-- so it's ok to use runNetProto, despite it not supporting
|
||||
|
@ -460,7 +455,3 @@ relayReader v hout = loop
|
|||
else getsome (b:bs)
|
||||
|
||||
chunk = 65536
|
||||
|
||||
getMonotonicTimestampIO :: IO MonotonicTimestamp
|
||||
getMonotonicTimestampIO = (MonotonicTimestamp . fromIntegral . Clock.sec)
|
||||
<$> Clock.getTime Clock.Monotonic
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue