[][src]Struct stakker::Share

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

Ref-counted shared mutable data

By default borrow-checking of access to the contents is handled at compile-time using a TCell or TLCell with its owner in Core. There are no access overheads at runtime. (With some feature settings, these would be replaced with QCell which does have some overhead.) Cloning has the normal Rc overheads.

Be careful using this because it can easily lead to dependency on the order of execution of actors. So treat this as similar in danger level to shared memory between threads or IPC shared memory between processes. You don't need locking however because if you get a mutable reference to the contents you'll have exclusive access until you give it up thanks to Rust's borrow checker.

Methods

impl<T> Share<T>[src]

pub fn new(core: &Core, val: T) -> Self[src]

Create a new Share instance

pub fn ro<'a>(&'a self, core: &'a Core) -> &'a T[src]

Get a read-only (immutable, shared) reference to the contents of the Share instance

pub fn rw<'a>(&'a self, core: &'a mut Core) -> &'a mut T[src]

Get a read-write (mutable, exclusive) reference to the contents of the Share instance

Trait Implementations

impl<T> Clone for Share<T>[src]

fn clone(&self) -> Self[src]

Return another reference to the shared data

Auto Trait Implementations

impl<T> !RefUnwindSafe for Share<T>

impl<T> !Send for Share<T>

impl<T> !Sync for Share<T>

impl<T> Unpin for Share<T>

impl<T> !UnwindSafe for Share<T>

Blanket Implementations

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

impl<T> Any for T where
    T: Any
[src]

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

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

impl<T> CloneAny for T where
    T: Clone + Any
[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.