LiveUpdate db updates working
I've tested the behavior of the thread that waits for the LiveUpdate to be finished, and it does get signaled and exit cleanly when the LiveUpdate is GCed instead. Made finishedLiveUpdate wait for the thread to finish updating the database. There is a case where GC doesn't happen in time and the database is left with a live update recorded in it. This should not be a problem as such stale data can also happen when interrupted and will need to be detected when loading the database. Balanced preferred content expressions now call startLiveUpdate.
This commit is contained in:
parent
84d1bb746b
commit
2f20b939b7
5 changed files with 55 additions and 38 deletions
|
@ -27,19 +27,11 @@ newtype MaxSize = MaxSize { fromMaxSize :: Integer }
|
|||
-- Used when an action is in progress that will change the current size of
|
||||
-- a repository.
|
||||
--
|
||||
-- The live update has been recorded as starting, and filling the MVar with
|
||||
-- the correct UUID, Key, and SizeChange will record the live update
|
||||
-- as complete. The Bool should be True when the action successfully
|
||||
-- added/removed the key from the repository.
|
||||
--
|
||||
-- If the MVar gets garbage collected before it is filled, the live update
|
||||
-- will be removed.
|
||||
--
|
||||
-- This allows other concurrent changes to the same repository take
|
||||
-- the changes to its size into account. If NoLiveUpdate is used, it
|
||||
-- prevents that.
|
||||
data LiveUpdate
|
||||
= LiveUpdate (MVar ()) (MVar (Bool, UUID, Key, SizeChange))
|
||||
= LiveUpdate (MVar ()) (MVar (UUID, Key, SizeChange)) (MVar ())
|
||||
| NoLiveUpdate
|
||||
|
||||
data SizeChange = AddingKey | RemovingKey
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue