Struct ste::Tagged[][src]

pub struct Tagged<T> { /* fields omitted */ }

An object T which can only be used on the thread with the corresponding tag.

Dropping tagged elements

Dropping a tagged container outside of its thread and the underlying T implements Drop will cause it to panic.

The correct way to drop it is to move it back onto the thread, use use the provided Thread::drop.

Examples

// Ensure that `Foo` is `!Send` and `!Sync`.
struct Foo(*mut ());

impl Foo {
    fn test(&self) -> u32 {
        42
    }
}

impl Drop for Foo {
    fn drop(&mut self) {
        println!("Foo was dropped");
    }
}

let thread = ste::Thread::new()?;

let value = thread.submit(|| ste::Tagged::new(Foo(0 as *mut ())))?;
let out = thread.submit(|| value.test())?;
assert_eq!(42, out);

thread.drop(value)?;
thread.join()?;

Implementations

impl<T> Tagged<T>[src]

pub fn new(target: T) -> Self[src]

Construct a new container tagged with the current thread.

Trait Implementations

impl<T> Deref for Tagged<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for Tagged<T>[src]

impl<T> Drop for Tagged<T>[src]

impl<T> Send for Tagged<T>[src]

impl<T> Sync for Tagged<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Tagged<T> where
    T: RefUnwindSafe

impl<T> Unpin for Tagged<T> where
    T: Unpin

impl<T> UnwindSafe for Tagged<T> where
    T: UnwindSafe

Blanket Implementations

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

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

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

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

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.