| Portability | non-portable (requires STM) |
|---|---|
| Stability | experimental |
| Maintainer | Peter Robinson <thaldyron@gmail.com> |
Control.Concurrent.TFile
Contents
Description
- data TFile k a
- new :: TBox t k a => k -> a -> AdvSTM (t k a)
- newIO :: TBox t k a => k -> a -> IO (t k a)
- newFromFileIO :: (Read k, TBox TFile k a) => FilePath -> IO (TFile k a, k)
- newEmpty :: TBox t k a => k -> AdvSTM (t k a)
- newEmptyIO :: TBox t k a => k -> IO (t k a)
- newEmptyFromFileIO :: (Read k, TBox TFile k a) => FilePath -> IO (TFile k a, k)
- read :: TBox t k a => t k a -> AdvSTM (Maybe a)
- write :: TBox t k a => t k a -> a -> AdvSTM ()
- clear :: TBox t k a => t k a -> AdvSTM ()
- isEmpty :: TBox t k a => t k a -> AdvSTM Bool
- basedir :: FilePath
Data type
A transactional variable that writes its content to a file on each update. The file is created in directory "./_TFile/".
newIO :: TBox t k a => k -> a -> IO (t k a)Source
Takes a key and an initial value. Has a default implementation.
newFromFileIO :: (Read k, TBox TFile k a) => FilePath -> IO (TFile k a, k)Source
Tries to construct a TFile from a given filepath.
Reads the content of the file into memory.
newEmptyIO :: TBox t k a => k -> IO (t k a)Source
Takes a key and returns an empty t. Has a default implementation.
newEmptyFromFileIO :: (Read k, TBox TFile k a) => FilePath -> IO (TFile k a, k)Source
Tries to construct a TFile from a given filepath.
Note that the content of the file is read into memory only on demand, i.e.,
when executing TBox.read.
Throws AssertionFailed if the filename could not be parsed.
Operations
read :: TBox t k a => t k a -> AdvSTM (Maybe a)Source
If the TBox is dirty, this retries the transaction and
rereads the content using readIO in a separate thread.
Otherwise it simply returns the result of readSTM.
Note: Depending on the instance implementation, careless
use of setDirty and read in the same transaction might lead
to nonterminating retry loops.