darwin-support-fixmes

This commit is contained in:
Dmitry Zuikov 2023-03-26 06:02:57 +03:00
parent 17bb6bd238
commit c16bedaea9
4 changed files with 20 additions and 0 deletions

View File

@ -1,4 +1,17 @@
## 2023-03-26
FIXME: macos-support-clock
-- CPP
-- | Use coarse clock timer. This timer has 1ms resolution but is much
-- faster comparing to the ordinary one. Is used on linux, on macos
-- provides ordinary one.
getTimeCoarse :: IO TimeSpec
#ifdef linux_HOST_OS
getTimeCoarse = getTime MonotonicCoarse
#else
getTimeCoarse = getTime Monotonic
#endif
## 2023-03-24 ## 2023-03-24

View File

@ -312,6 +312,7 @@ instance HasPeerLocator e m => HasPeerLocator e (BlockDownloadM e m) where
updatePeerInfo :: MonadIO m => Bool -> PeerInfo e -> m () updatePeerInfo :: MonadIO m => Bool -> PeerInfo e -> m ()
updatePeerInfo onError pinfo = do updatePeerInfo onError pinfo = do
-- FIXME: macos-support-3
t1 <- liftIO $ getTime MonotonicCoarse t1 <- liftIO $ getTime MonotonicCoarse
void $ liftIO $ atomically $ do void $ liftIO $ atomically $ do

View File

@ -204,6 +204,7 @@ fetchBlockState :: MonadIO m => Hash HbSync -> BlockDownloadM e m BlockState
fetchBlockState h = do fetchBlockState h = do
sh <- asks (view blockState) sh <- asks (view blockState)
liftIO do liftIO do
-- FIXME: macos-support-2
now <- getTime MonotonicCoarse now <- getTime MonotonicCoarse
tvlast <- newTVarIO now tvlast <- newTVarIO now
tvreq <- newTVarIO 0 tvreq <- newTVarIO 0
@ -231,6 +232,7 @@ delBlockState h = do
incBlockSizeReqCount :: MonadIO m => Hash HbSync -> BlockDownloadM e m () incBlockSizeReqCount :: MonadIO m => Hash HbSync -> BlockDownloadM e m ()
incBlockSizeReqCount h = do incBlockSizeReqCount h = do
blk <- fetchBlockState h blk <- fetchBlockState h
-- FIXME: macos-support-4
now <- liftIO $ getTime MonotonicCoarse now <- liftIO $ getTime MonotonicCoarse
seen <- liftIO $ readTVarIO (view bsLastSeen blk) seen <- liftIO $ readTVarIO (view bsLastSeen blk)
let elapsed = realToFrac (toNanoSecs (now - seen)) / 1e9 let elapsed = realToFrac (toNanoSecs (now - seen)) / 1e9

View File

@ -104,6 +104,10 @@ touchForRead ss k = liftIO $ do
Nothing -> do Nothing -> do
bsmm <- unsafeMMapFile (simpleBlockFileName ss k) bsmm <- unsafeMMapFile (simpleBlockFileName ss k)
-- FIXME: macos-support-1
-- вынести функцию в библиотеку
-- обернуть в CPP
tick <- getTime MonotonicCoarse tick <- getTime MonotonicCoarse
atomically $ do atomically $ do