This commit is contained in:
Dmitry Zuikov 2023-01-25 13:14:31 +03:00
parent b29d17aa4a
commit f0c4756b11
2 changed files with 9 additions and 8 deletions

View File

@ -67,7 +67,7 @@ data ChunkWriter h m = forall a . ( MonadIO m
, pipeline :: Pipeline m () , pipeline :: Pipeline m ()
, dir :: FilePath , dir :: FilePath
, storage :: a , storage :: a
, perBlock :: Cache FilePath (TQueue (Handle -> IO ())) , perBlock :: Cache FilePath (TQueue (IO ()))
, perBlockSem :: Cache FilePath TSem , perBlockSem :: Cache FilePath TSem
} }
@ -276,8 +276,8 @@ writeChunk2 w salt h o bs = do
liftIO $ do liftIO $ do
q <- Cache.fetchWithCache cache fn $ const Q0.newTQueueIO q <- Cache.fetchWithCache cache fn $ const Q0.newTQueueIO
atomically $ Q0.writeTQueue q $ \fh -> do atomically $ Q0.writeTQueue q $ do
-- withBinaryFile fn ReadWriteMode $ \fh -> do withBinaryFile fn ReadWriteMode $ \fh -> do
hSeek fh AbsoluteSeek (fromIntegral o) hSeek fh AbsoluteSeek (fromIntegral o)
B.hPutStr fh bs B.hPutStr fh bs
-- hFlush fh -- hFlush fh
@ -334,8 +334,8 @@ flush w fn = do
liftIO $ do liftIO $ do
-- withBinaryFile fn ReadWriteMode $ \fh -> do -- withBinaryFile fn ReadWriteMode $ \fh -> do
withBinaryFile fn ReadWriteMode $ \fh -> do -- withBinaryFile fn ReadWriteMode $ \fh -> do
for_ flushed $ \f -> f fh for_ flushed id
atomically $ Sem.signalTSem s atomically $ Sem.signalTSem s

View File

@ -50,10 +50,11 @@ main = do
w2 <- replicateM 1 $ async $ runChunkWriter cw w2 <- replicateM 1 $ async $ runChunkWriter cw
-- psz' <- shuffleM psz psz' <- shuffleM psz
psz' <- pure psz -- psz' <- pure psz
forConcurrently_ psz' $ \(o,s) -> do -- forConcurrently_ psz' $ \(o,s) -> do
forM_ psz' $ \(o,s) -> do
let t = B8.take s $ B8.drop o bytes let t = B8.take s $ B8.drop o bytes
writeChunk cw 1 hash (fromIntegral o) t writeChunk cw 1 hash (fromIntegral o) t