Struct tiny_future::Future [−][src]
pub struct Future<T, U = ()>(_);
Methods
impl<T, U> Future<T, U>
[src]
impl<T, U> Future<T, U>
pub fn with_state(shared_state: U) -> Self
[src]
pub fn with_state(shared_state: U) -> Self
Creates a new Future<T, U>
with shared_state
as shared-state
pub fn set(&self, result: T) -> Result<(), Error<State>>
[src]
pub fn set(&self, result: T) -> Result<(), Error<State>>
Sets the future
pub fn cancel(&self)
[src]
pub fn cancel(&self)
Cancels (poisons) the future
This is useful to indicate that the future is obsolete and should not be set
anymore
pub fn get_state(&self) -> State
[src]
pub fn get_state(&self) -> State
Returns the future's state
pub fn is_waiting(&self) -> bool
[src]
pub fn is_waiting(&self) -> bool
Checks if the future is still waiting or has been set/canceled
pub fn try_get(&self) -> Result<T, Error<State>>
[src]
pub fn try_get(&self) -> Result<T, Error<State>>
Tries to get the future's result
If the future is ready, it is consumed and T
is returned;
if the future is not ready, Error::InvalidState(State)
is returned
pub fn try_get_timeout(&self, timeout: Duration) -> Result<T, Error<State>>
[src]
pub fn try_get_timeout(&self, timeout: Duration) -> Result<T, Error<State>>
Tries to get the future's result
If the future is ready or or becomes ready before the timeout occurres, it is consumed
and T
is returned; if the future is not ready, Error::InvalidState(State)
is returned
pub fn get(&self) -> Result<T, Error<State>>
[src]
pub fn get(&self) -> Result<T, Error<State>>
Gets the future's result
Warning: this function will block until a result becomes available
Get a clone of the current shared state
Replace the current shared state
Provides exclusive access to the shared state within modifier
until modifier
returns
Provides exclusive access to the shared state within modifier
until modifier
returns
pub fn detach(&self)
[src]
pub fn detach(&self)
Detaches the future so it won't be canceled if there is only one instance left
Useful if you either don't want that your future is ever canceled or if there's always only one instance (e.g. if you wrap it into a reference-counting container)
impl<T> Future<T, ()>
[src]
impl<T> Future<T, ()>
Trait Implementations
impl<T, U> Default for Future<T, U> where
U: Default,
[src]
impl<T, U> Default for Future<T, U> where
U: Default,
impl<T, U> Drop for Future<T, U>
[src]
impl<T, U> Drop for Future<T, U>
impl<T, U> Clone for Future<T, U>
[src]
impl<T, U> Clone for Future<T, U>
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T, U> Send for Future<T, U>
[src]
impl<T, U> Send for Future<T, U>
impl<T, U> Sync for Future<T, U>
[src]
impl<T, U> Sync for Future<T, U>