Struct corundum::AssertTxInSafe
source · [−]pub struct AssertTxInSafe<T>(pub T);
Expand description
A simple wrapper around a type to assert that it is safe to go in a transaction.
When using transaction
it may be the case that some of the closed over
variables are not TxInSafe
safe. For example if &mut T
is captured the
compiler will generate a warning indicating that it is not TxInSafe
. It
may not be the case, however, that this is actually a problem due to the
specific usage of transaction
if transaction inward safety is
specifically taken into account. This wrapper struct is useful for a quick
and lightweight annotation that a variable is indeed TxInSafe
at the
programmer’s responsibilities. The Journal
object cannot be wrapped by
AssertTxInSafe
to make sure no inter-pool pointer can be made.
Examples
You may wrap individual captures, as shown below. This ensures that if a new
capture is added which is not TxInSafe
, you will get a compilation error
at that time, which will allow you to consider whether that new capture in
fact represent a bug or not.
use corundum::alloc::heap::*;
use corundum::AssertTxInSafe;
let mut variable = 4;
let other_capture = 3;
let result = {
let mut wrapper = AssertTxInSafe(&mut variable);
Heap::transaction(move |_| {
**wrapper += other_capture;
})
};
assert_eq!(variable, 7);
// ...
Tuple Fields
0: T
Trait Implementations
sourceimpl<T: Debug + LooseTxInUnsafe> Debug for AssertTxInSafe<T>
impl<T: Debug + LooseTxInUnsafe> Debug for AssertTxInSafe<T>
sourceimpl<T: LooseTxInUnsafe> Deref for AssertTxInSafe<T>
impl<T: LooseTxInUnsafe> Deref for AssertTxInSafe<T>
sourceimpl<T: LooseTxInUnsafe> DerefMut for AssertTxInSafe<T>
impl<T: LooseTxInUnsafe> DerefMut for AssertTxInSafe<T>
sourceimpl<R, P: MemPool, F> FnOnce(&'static Journal<P>) for AssertTxInSafe<F> where
R: TxOutSafe,
F: FnOnce(&'static Journal<P>) -> R,
impl<R, P: MemPool, F> FnOnce(&'static Journal<P>) for AssertTxInSafe<F> where
R: TxOutSafe,
F: FnOnce(&'static Journal<P>) -> R,
sourceimpl<F: Future + LooseTxInUnsafe> Future for AssertTxInSafe<F>
impl<F: Future + LooseTxInUnsafe> Future for AssertTxInSafe<F>
impl<T: LooseTxInUnsafe> RefUnwindSafe for AssertTxInSafe<T>
impl<T: LooseTxInUnsafe> TxInSafe for AssertTxInSafe<T>
impl<T: LooseTxInUnsafe> UnwindSafe for AssertTxInSafe<T>
Auto Trait Implementations
impl<T> LooseTxInUnsafe for AssertTxInSafe<T> where
T: LooseTxInUnsafe,
impl<T> PSafe for AssertTxInSafe<T> where
T: PSafe,
impl<T> PSend for AssertTxInSafe<T> where
T: PSend,
impl<T> Send for AssertTxInSafe<T> where
T: Send,
impl<T> Sync for AssertTxInSafe<T> where
T: Sync,
impl<T> TxOutSafe for AssertTxInSafe<T> where
T: TxOutSafe,
impl<T> Unpin for AssertTxInSafe<T> where
T: Unpin,
impl<T> VSafe for AssertTxInSafe<T> where
T: VSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<F> IntoFuture for F where
F: Future,
impl<F> IntoFuture for F where
F: Future,
type Output = <F as Future>::Output
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type IntoFuture = F
type IntoFuture = F
into_future
)Which kind of future are we turning this into?
sourcefn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
into_future
)Creates a future from a value.