[][src]Struct swym::tx::Error

pub struct Error { /* fields omitted */ }

Error type indicating that the transaction has failed.

It is typical to route this error back to ThreadKey::rw or ThreadKey::read where the transaction will be retried, however, this is not required.

Notes

Any additional operations on any TCell that has returned Error will continue to return errors for the remainder of the transaction.

Methods

impl Error[src]

pub const RETRY: Self[src]

Error value requesting a retry of the current transaction.

Notes

Returning RETRY to ThreadKey::read or ThreadKey::rw will immediately restart the transaction. This can cause the thread to spin, hurting the performance of other threads. In the future, the behavior of RETRY may change.

Examples

use swym::{tcell::TCell, thread_key, tx::Error};

let thread_key = thread_key::get();
let locked = TCell::new(false);

thread_key.rw(|tx| {
    if locked.get(tx, Default::default())? {
        Err(Error::RETRY)
    } else {
        Ok(locked.set(tx, true)?)
    }
})

Trait Implementations

impl Eq for Error[src]

impl PartialEq<Error> for Error[src]

impl<T> From<SetError<T>> for Error[src]

impl Debug for Error[src]

Auto Trait Implementations

impl Send for Error

impl Sync for Error

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.