Struct corundum::stm::Journal [−][src]
pub struct Journal<A: MemPool> { /* fields omitted */ }
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
impl<A: MemPool> Journal<A>
[src]
pub unsafe fn new(gen: u32) -> Self
[src]
Create new Journal
with default values
pub fn gen(&self) -> u32
[src]
Returns the generation number of this journal
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 unsafe fn enter_into(&mut self, head_off: &u64, zone: usize)
[src]
Atomically enters into the list journals of the owner pool
pub fn recovery_info(&self, info_level: u32) -> String
[src]
Returns a string containing the logging information
pub unsafe fn commit(&mut self)
[src]
Commits all logs in the journal
pub unsafe fn rollback(&mut self)
[src]
Reverts all changes
pub unsafe fn recover(&mut self)
[src]
Recovers from a crash or power failure
pub unsafe 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 u64::MAX
pub unsafe fn prev_off(&self) -> u64
[src]
Returns the offset of the previous journal, if any. Otherwise, returns u64::MAX
pub unsafe fn next_off_ref(&self) -> &u64
[src]
pub unsafe fn prev_off_ref(&self) -> &u64
[src]
pub fn is_running() -> bool
[src]
Returns true if there is a running transaction on the current thread
pub unsafe fn ignore(&self)
[src]
Ignores all logs
This function is only for measuring some properties such as log latency.
Trait Implementations
impl<A: MemPool> Debug for Journal<A>
[src]
impl<A: MemPool> !LooseTxInUnsafe for Journal<A>
[src]
impl<A: MemPool> !PSafe 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> PSend for Journal<A> where
A: PSend,
A: PSend,
impl<A> Unpin for Journal<A> where
A: Unpin,
A: Unpin,
impl<A> VSafe for Journal<A> where
A: VSafe,
A: VSafe,
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>,