This commit is contained in:
voidlizard 2025-07-29 14:40:52 +03:00
parent 9e5247f19c
commit 29d5025e19
3 changed files with 6 additions and 7 deletions

View File

@ -42,7 +42,7 @@ ncqLookupIndex hx (mmaped, nway) = do
ncqIndexFile :: MonadUnliftIO m => NCQStorage3 -> DataFile FileKey -> m (Maybe FilePath) ncqIndexFile :: MonadUnliftIO m => NCQStorage3 -> DataFile FileKey -> m (Maybe FilePath)
ncqIndexFile n@NCQStorage3{..} fk = runMaybeT do ncqIndexFile n fk = runMaybeT do
let fp = toFileName fk & ncqGetFileName n let fp = toFileName fk & ncqGetFileName n
fki <- ncqGetNewFileKey n IndexFile fki <- ncqGetNewFileKey n IndexFile

View File

@ -56,7 +56,6 @@ ncqStorageRun3 ncq@NCQStorage3{..} = flip runContT pure do
if not stop then STM.retry else pure Nothing if not stop then STM.retry else pure Nothing
maybe1 what none $ \(fk :: FileKey, fh) -> do maybe1 what none $ \(fk :: FileKey, fh) -> do
notice $ red "CLOSE FILE" <+> pretty fk
closeFd fh closeFd fh
ncqIndexFile ncq (DataFile fk) ncqIndexFile ncq (DataFile fk)
loop loop
@ -66,8 +65,7 @@ ncqStorageRun3 ncq@NCQStorage3{..} = flip runContT pure do
let q = ncqWriteOps ! i let q = ncqWriteOps ! i
forever (liftIO $ join $ atomically (readTQueue q)) forever (liftIO $ join $ atomically (readTQueue q))
replicateM_ 2 $ spawnActivity $ fix \next -> do
replicateM_ 1 $ spawnActivity $ fix \next -> do
(h, answ) <- atomically $ readTQueue ncqReadReq (h, answ) <- atomically $ readTQueue ncqReadReq
let answer l = atomically (putTMVar answ l) let answer l = atomically (putTMVar answ l)
@ -117,7 +115,9 @@ ncqStorageRun3 ncq@NCQStorage3{..} = flip runContT pure do
pure w pure w
else do else do
appendTailSection fh >> liftIO (fileSynchronise fh) appendTailSection fh >> liftIO (fileSynchronise fh)
ss <- liftIO (PFS.getFdStatus fh) <&> fromIntegral . PFS.fileSize ss <- liftIO (PFS.getFdStatus fh) <&> fromIntegral . PFS.fileSize
ncqStateUpdate ncq do ncqStateUpdate ncq do
ncqStateAddFact (P (PData (DataFile fk) ss)) ncqStateAddFact (P (PData (DataFile fk) ss))
@ -172,8 +172,7 @@ ncqStorageRun3 ncq@NCQStorage3{..} = flip runContT pure do
let written = sum ws let written = sum ws
loop $ RunSync (fk, fh, w + written, total' + written, True) loop $ RunSync (fk, fh, w + written, total' + written, True)
wait closer
pure ()
where where
setAlive = atomically $ writeTVar ncqAlive True setAlive = atomically $ writeTVar ncqAlive True

View File

@ -98,7 +98,7 @@ readStateMay sto key = fmap sortIndexes <$> do
flip fix (ncqState0, sexps) $ \next -> \case flip fix (ncqState0, sexps) $ \next -> \case
(acc, []) -> pure acc (acc, []) -> pure acc
(acc, e : ss) -> liftIO (print (pretty e)) >> next (acc <> entryOf e, ss) (acc, e : ss) -> next (acc <> entryOf e, ss)
where where