Trait Stack

Source
pub trait Stack<T>: Default {
    type PushReq: From<T> + Deref<Target = ManuallyDrop<T>>;

    // Required methods
    fn try_push(
        &self,
        req: Owned<Self::PushReq>,
        guard: &Guard,
    ) -> Result<(), Owned<Self::PushReq>>;
    fn try_pop(&self, guard: &Guard) -> Result<Option<T>, ()>;
    fn is_empty(&self, guard: &Guard) -> bool;

    // Provided methods
    fn push(&self, t: T) { ... }
    fn pop(&self) -> Option<T> { ... }
}
Expand description

Concurrent stack types.

Required Associated Types§

Source

type PushReq: From<T> + Deref<Target = ManuallyDrop<T>>

Push request type.

Required Methods§

Source

fn try_push( &self, req: Owned<Self::PushReq>, guard: &Guard, ) -> Result<(), Owned<Self::PushReq>>

Tries to push a value to the stack.

Returns Ok(()) if the push request is served; Err(req) is CAS failed.

Source

fn try_pop(&self, guard: &Guard) -> Result<Option<T>, ()>

Tries to pop a value from the stack.

Returns Ok(Some(v)) if v is popped; Ok(None) if the stack is empty; and Err(()) if CAS failed.

Source

fn is_empty(&self, guard: &Guard) -> bool

Returns true if the stack is empty.

Provided Methods§

Source

fn push(&self, t: T)

Pushes a value to the stack.

Source

fn pop(&self) -> Option<T>

Pops a value from the stack.

Returns Some(v) if v is popped; None if the stack is empty.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Stack<T> for TreiberStack<T>

Source§

impl<T, S: Stack<T>> Stack<T> for ElimStack<T, S>

Source§

type PushReq = <S as Stack<T>>::PushReq