Struct trillium_server_common::CloneCounter [−][src]
pub struct CloneCounter(_);
Expand description
an atomic counter that increments on clone & decrements on drop
use futures_lite::future::poll_once; let counter = CloneCounter::new(); assert_eq!(counter.current(), 0); counter.await; // ready immediately let counter = CloneCounter::new(); assert_eq!(counter.current(), 0); let clone = counter.clone(); assert_eq!(counter.current(), 1); let clone2 = counter.clone(); assert_eq!(counter.current(), 2); assert_eq!(poll_once(clone2).await, None); // pending assert_eq!(counter.current(), 1); std::mem::drop(clone); assert_eq!(counter.current(), 0); counter.await; // ready
Implementations
Returns the current count. The first CloneCounter is zero, so this can either be considered a zero-indexed count of the total number of CloneCounters in memory, or a one-indexed count of the number of non-original clones.
Manually decrement the count. This is useful when taking a clone of the counter that does not represent an increase in the underlying property or resource being counted. This is called automatically on drop and is usually unnecessary to call directly
Trait Implementations
fn default() -> CloneCounterⓘNotable traits for CloneCounter
impl Future for CloneCounter type Output = ();
fn default() -> CloneCounterⓘNotable traits for CloneCounter
impl Future for CloneCounter type Output = ();Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for CloneCounterimpl Send for CloneCounterimpl Sync for CloneCounterimpl Unpin for CloneCounterimpl !UnwindSafe for CloneCounterBlanket Implementations
Mutably borrows from an owned value. Read more
A convenience for calling Future::poll() on !Unpin types.
Returns the result of self or other future, preferring self if both are ready. Read more
Returns the result of self or other future, with no preference if both are ready. Read more
Catches panics while polling the future. Read more
Boxes the future and changes its type to dyn Future + Send + 'a. Read more
into_future)The output that the future will produce on completion.
type Future = F
type Future = Finto_future)Which kind of future are we turning this into?
into_future)Creates a future from a value.
pub fn vzip(self) -> V