Struct corundum::stm::Journal [−][src]
pub struct Journal<A: MemPool> { /* fields omitted */ }
Expand description
A Journal object to be used for writing logs onto
Each transaction, hence each thread, may have only one journal for every
memory pool to write the logs. The journal itself resides in a pool.
Journals are linked together in the MemPool
object to be accessible in
recovery procedure.
It is not allowed to create a Journal
object. However, transaction()
creates a journal at the beginning and passes a reference to it to the body
closure. So, to obtain a reference to a Journal
, you may wrap a
transaction around your code. For example:
use corundum::alloc::heap::*; let cell = Heap::transaction(|journal| { let cell = Pbox::new(PCell::new(10), journal); assert_eq!(cell.get(), 10); }).unwrap();
A Journal
consists of one or more page
s. A page
provides a fixed
number of log slots which is specified by PAGE_SIZE
(64). This helps
performance as the logs are pre-allocated. When the number of logs in a page
exceeds 64, Journal
object atomically allocate a new page for another 64
pages before running the operations.
Journal
s by default are deallocated after the transaction or recovery.
However, it is possible to pin journals in the pool if they are used
frequently by enabling “pin_journals” feature.
Implementations
Returns true if the journal is committed
Atomically enters into the list journals of the owner pool
Returns a string containing the logging information
Determines whether to fast-forward or rollback the transaction on recovery according to the following table:
┌───────────┬────────────┬──────────┬─────┐ │ Committed │ Chaperoned │ Complete │ FF │ ╞═══════════╪════════════╪══════════╪═════╡ │ TRUE │ FALSE │ X │ YES │ │ TRUE │ TRUE │ TRUE │ YES │ │ TRUE │ TRUE │ FALSE │ NO │ │ FALSE │ X │ X │ NO │ └───────────┴────────────┴──────────┴─────┘
Fast-forward means that no matter the transaction is committed or not, if there exist logs, discard them all without rolling back.
States:
- Committed: Transaction is already committed but not complete (Logs still exist).
- Chaperoned: The transaction was attached to a
Chaperon::transaction
. - Complete: The
Chaperon::transaction
is complete.
Returns the offset of the next journal, if any. Otherwise, returns u64::MAX
Returns the offset of the previous journal, if any. Otherwise, returns u64::MAX
Returns a journal for the current thread. If there is no Journal
object for the running thread, it may create a new journal and returns
its mutable reference. Each thread may have only one journal.
Returns true if there is a running transaction on the current thread