Struct corundum::AssertTxInSafe [−][src]
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); // ...
Trait Implementations
async_stream
)The type of items yielded by the stream.
async_stream
)Attempt to pull out the next value of this stream, registering the
current task for wakeup if the value is not yet available, and returning
None
if the stream is exhausted. Read more
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
Mutably borrows from an owned value. Read more
into_future
)The output that the future will produce on completion.
type Future = F
type Future = F
into_future
)Which kind of future are we turning this into?
into_future
)Creates a future from a value.