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 duplicate 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.