[−][src]Struct crndm::stm::journal::Journal
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 crndm::alloc::*; use crndm::boxed::Pbox; use crndm::cell::LogCell; let cell = Heap::transaction(|journal| { let cell = Pbox::new(LogCell::new(10, journal), 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
impl<A: MemPool> Journal<A>
[src]
pub unsafe fn new() -> Self
[src]
Create new Journal
with default values
pub fn is_committed(&self) -> bool
[src]
Returns true if the journal is committed
pub fn is_set(&self, flag: u64) -> bool
[src]
Checks a flag
pub fn enter_into(&mut self, head_off: &u64)
[src]
Atomically enters into the list journals of the owner pool
pub fn commit(&mut self)
[src]
Commits all logs in the journal
pub fn rollback(&mut self)
[src]
Reverts all changes
pub fn recover(&mut self)
[src]
Recovers from a crash or power failure
pub fn clear(&mut self)
[src]
Clears all logs and drops itself from the memory pool
pub fn fast_forward(&self) -> bool
[src]
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.
pub unsafe fn next_off(&self) -> u64
[src]
Returns the offset of the next journal, if any. Otherwise, returns zero
Trait Implementations
impl<A: MemPool> Debug for Journal<A>
[src]
impl<A: MemPool> !LooseTxInUnsafe for Journal<A>
[src]
impl<A: MemPool> !RefUnwindSafe for Journal<A>
[src]
impl<A: MemPool> !Send for Journal<A>
[src]
impl<A: MemPool> !Sync for Journal<A>
[src]
impl<A: MemPool> !TxInSafe for Journal<A>
[src]
impl<A: MemPool> !TxOutSafe for Journal<A>
[src]
impl<A: MemPool> !UnwindSafe for Journal<A>
[src]
Auto Trait Implementations
impl<A> PSafe for Journal<A>
[src]
impl<A> Unpin for Journal<A> where
A: Unpin,
[src]
A: Unpin,
impl<A> !VSafe for Journal<A>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,