[−][src]Struct tokio::prelude::task::TaskRc
: replaced with BiLock
in many cases, otherwise slated for removal due to confusion
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
.
Methods
impl<A> TaskRc<A>
[src]
impl<A> TaskRc<A>
pub fn new(a: A) -> TaskRc<A>
[src]
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.
pub fn with<F, R>(&self, f: F) -> R where
F: FnOnce(&A) -> R,
[src]
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> Sync for TaskRc<A> where
A: Sync,
[src]
impl<A> Sync for TaskRc<A> where
A: Sync,
impl<A> Send for TaskRc<A> where
A: Send,
[src]
impl<A> Send for TaskRc<A> where
A: Send,
impl<A> Debug for TaskRc<A> where
A: Debug,
[src]
impl<A> Debug for TaskRc<A> where
A: Debug,
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<A> Clone for TaskRc<A>
[src]
impl<A> Clone for TaskRc<A>
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
ⓘImportant traits for &'a mut Wfn borrow(&self) -> &T
[src]
fn borrow(&self) -> &T
Immutably borrows from an owned value. Read more
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
ⓘImportant traits for &'a mut Wfn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
[src]
impl<T> Erased for T