Skip to content

Commit

Permalink
check invariant after supplying credits
Browse files Browse the repository at this point in the history
  • Loading branch information
mheinzel committed Aug 20, 2024
1 parent 6f15601 commit 77c4bb4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions prototypes/ScheduledMerges.hs
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,12 @@ update tr (LSMHandle scr lsmr) k op = do
LSMContent wb ls <- readSTRef lsmr
modifySTRef' scr (+1)
supplyCredits 1 ls
invariant ls
let wb' = Map.insert k op wb
if bufferSize wb' >= maxBufferSize
then do
ls' <- increment tr sc (bufferToRun wb') ls
invariant ls'
writeSTRef lsmr (LSMContent Map.empty ls')
else
writeSTRef lsmr (LSMContent wb' ls)
Expand Down Expand Up @@ -531,9 +533,7 @@ data EventDetail =
increment :: forall s. Tracer (ST s) Event
-> Counter -> Run -> Levels s -> ST s (Levels s)
increment tr sc = \r ls -> do
ls' <- go 1 [r] ls
invariant ls'
return ls'
go 1 [r] ls
where
go :: Int -> [Run] -> Levels s -> ST s (Levels s)
go !ln incoming [] = do
Expand Down

0 comments on commit 77c4bb4

Please sign in to comment.