pub struct TaskRc<A> { /* private fields */ }
replaced with BiLock
in many cases, otherwise slated for removal due to confusion
Expand description
A reference to a piece of data that’s accessible only within a specific
Task
.
This data is Send
even when A
is not Sync
, because the data stored
within is accessed in a single-threaded way. The thread accessing it may
change over time, if the task migrates, so A
must be Send
.
Implementations
sourceimpl<A> TaskRc<A>
impl<A> TaskRc<A>
sourcepub fn new(a: A) -> TaskRc<A>
👎 Deprecated since 0.1.4: replaced with BiLock
in many cases, otherwise slated for removal due to confusion
pub fn new(a: A) -> TaskRc<A>
replaced with BiLock
in many cases, otherwise slated for removal due to confusion
Inserts a new piece of task-local data into this task, returning a reference to it.
Ownership of the data will be transferred to the task, and the data will
be destroyed when the task itself is destroyed. The returned value can
be passed to the with
method to get a reference back to the original
data.
Note that the returned handle is cloneable and copyable and can be sent to other futures which will be associated with the same task. All futures will then have access to this data when passed the reference back.
Panics
This function will panic if a task is not currently running.
sourcepub fn with<F, R>(&self, f: F) -> R where
F: FnOnce(&A) -> R,
👎 Deprecated since 0.1.4: replaced with BiLock
in many cases, otherwise slated for removal due to confusion
pub fn with<F, R>(&self, f: F) -> R where
F: FnOnce(&A) -> R,
replaced with BiLock
in many cases, otherwise slated for removal due to confusion
Operate with a reference to the underlying data.
This method should be passed a handle previously returned by
Task::insert
. That handle, when passed back into this method, will
retrieve a reference to the original data.
Panics
This method will panic if a task is not currently running or if self
does not belong to the task that is currently running. That is, if
another task generated the data
handle passed in, this method will
panic.
Trait Implementations
impl<A> Send for TaskRc<A> where
A: Send,
impl<A> Sync for TaskRc<A> where
A: Sync,
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more