Safe Haskell | Safe |
---|---|
Language | Haskell98 |
A brief note on the locking strategy:
A Columbia data file is covered by three locks: a dual lock (comprising two locks) and a writer lock; the lock hierarchy goes in that order. The dual lock is taken in a shared mode during all reading. The only circumstance in which the dual lock is taken in exclusive mode is to execute the write phase of a garbage collection.
The writer lock protects the action of writing to the end of the file and also to the root node offset; readers take the writer lock only during reading the root node offset; the writer lock is always taken in exclusive mode.
The high level view is: you can always run the collector in parallel with any other operation you are doing; you can read and write freely while using the collector.
- markAndSweepGc :: FilePath -> [IORef Pointer] -> IO ()
Documentation
markAndSweepGc :: FilePath -> [IORef Pointer] -> IO () Source #
Garbage collection for files. It is a good idea when using garbage collection, never to be holding addresses into a file when releasing that file's lock, as at that point the garbage collector may move the data referenced. There is also a pattern, where only one thread runs the garbage collector; in that case, the collector thread may hold addresses and have these updated when the garbage collector moves data.