pub struct Journal<A: MemPool> { /* private fields */ }
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 pages. 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.

Journals 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

Create new Journal with default values

Returns the generation number of this journal

Returns true if the journal is committed

Sets a flag

Resets a flag

Checks a flag

Atomically enters into the list journals of the owner pool

Returns a string containing the logging information

Commits all logs in the journal

Reverts all changes

Recovers from a crash or power failure

Clears all logs and drops itself from the memory pool

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:

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

Ignores all logs

This function is only for measuring some properties such as log latency.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.