switch back to POSIXTime
turned out not to need Read MeterState
This commit is contained in:
parent
31e417f351
commit
e5b170aa1c
1 changed files with 4 additions and 4 deletions
|
@ -382,8 +382,8 @@ data Meter = Meter (MVar (Maybe Integer)) (MVar MeterState) (MVar String) Displa
|
||||||
|
|
||||||
data MeterState = MeterState
|
data MeterState = MeterState
|
||||||
{ meterBytesProcessed :: BytesProcessed
|
{ meterBytesProcessed :: BytesProcessed
|
||||||
, meterTimeStamp :: Double
|
, meterTimeStamp :: POSIXTime
|
||||||
} deriving (Show, Read)
|
} deriving (Show)
|
||||||
|
|
||||||
type DisplayMeter = MVar String -> Maybe Integer -> MeterState -> MeterState -> IO ()
|
type DisplayMeter = MVar String -> Maybe Integer -> MeterState -> MeterState -> IO ()
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ type RenderMeter = Maybe Integer -> MeterState -> MeterState -> String
|
||||||
-- | Make a meter. Pass the total size, if it's known.
|
-- | Make a meter. Pass the total size, if it's known.
|
||||||
mkMeter :: Maybe Integer -> DisplayMeter -> IO Meter
|
mkMeter :: Maybe Integer -> DisplayMeter -> IO Meter
|
||||||
mkMeter totalsize displaymeter = do
|
mkMeter totalsize displaymeter = do
|
||||||
ts <- realToFrac <$> getPOSIXTime
|
ts <- getPOSIXTime
|
||||||
Meter
|
Meter
|
||||||
<$> newMVar totalsize
|
<$> newMVar totalsize
|
||||||
<*> newMVar (MeterState zeroBytesProcessed ts)
|
<*> newMVar (MeterState zeroBytesProcessed ts)
|
||||||
|
@ -405,7 +405,7 @@ setMeterTotalSize (Meter totalsizev _ _ _) = void . swapMVar totalsizev . Just
|
||||||
-- | Updates the meter, displaying it if necessary.
|
-- | Updates the meter, displaying it if necessary.
|
||||||
updateMeter :: Meter -> MeterUpdate
|
updateMeter :: Meter -> MeterUpdate
|
||||||
updateMeter (Meter totalsizev sv bv displaymeter) new = do
|
updateMeter (Meter totalsizev sv bv displaymeter) new = do
|
||||||
now <- realToFrac <$> getPOSIXTime
|
now <- getPOSIXTime
|
||||||
let curms = MeterState new now
|
let curms = MeterState new now
|
||||||
oldms <- swapMVar sv curms
|
oldms <- swapMVar sv curms
|
||||||
when (meterBytesProcessed oldms /= new) $ do
|
when (meterBytesProcessed oldms /= new) $ do
|
||||||
|
|
Loading…
Reference in a new issue