kanzi::thread_object

Struct ThreadObject

pub struct ThreadObject<T>(/* private fields */);
Expand description

ThreadObject represents a weak reference to a Kanzi object.

It exists primarily to allow Objects to be shared safely between multiple threads. To create a ThreadObject, call the ThreadObject::downgrade function. To convert a ThreadObject back to an owned object, call ThreadObject::upgrade.

Implementations§

§

impl<T> ThreadObject<T>

pub fn upgrade(self, domain: &Domain) -> Result<Option<T>, Error>

Upgrades a ThreadObject to an owned object of the same type. If None is returned, the object has been destroyed.

pub fn unlock(self, domain: &Domain) -> Weak<T>

Unlocks a ThreadObject to a Weak object of the same type.

pub fn downgrade(object: T) -> ThreadObject<T>

Downgrades an object to a thread object of the same type.

pub fn downgrade_ref(object: &T) -> ThreadObject<T>

Downgrades an object reference to a thread object of the same type.

Methods from Deref<Target = ThreadObjectInner<T>>§

pub fn upgrade_ref(&self, domain: &Domain) -> Result<Option<T>, Error>

Upgrades a ThreadObject reference to an owned object of the same type. If None is returned, the object has been destroyed.

pub fn unlock_ref(&self, domain: &Domain) -> Weak<T>

Unlocks a ThreadObject reference to a Weak reference of the same type.

Trait Implementations§

§

impl<T> Clone for ThreadObject<T>
where T: Clone,

§

fn clone(&self) -> ThreadObject<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Deref for ThreadObject<T>

§

type Target = ThreadObjectInner<T>

The resulting type after dereferencing.
§

fn deref(&self) -> &<ThreadObject<T> as Deref>::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<T> Freeze for ThreadObject<T>

§

impl<T> RefUnwindSafe for ThreadObject<T>
where T: RefUnwindSafe,

§

impl<T> Send for ThreadObject<T>

§

impl<T> Sync for ThreadObject<T>

§

impl<T> Unpin for ThreadObject<T>

§

impl<T> UnwindSafe for ThreadObject<T>
where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Inherits<T> for T

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.