enum Impl {
Preferred(PreferredRuntime),
Dyn(Box<dyn DynProvider>),
}Expand description
Actual contents of a DynTimeProvider
We optimise the PreferredRuntime case.
We could, instead, just use Box<dyn DynProvider> here.
The reason for doing it this way is that we expect this to be on many hot paths. Putting a message in a queue is extremely common, and we’d like to save a dyn dispatch, and reference to a further heap entry (which might be distant in the cache).
(Also, it’s nice to avoid boxing when we crate new types that use this,
including our memory-quota-tracked mpsc streams, see tor-memquota::mq_queue.
The downside is that this means:
- This enum instead of a simple type
- The
unsafeinsidedowncast_value. matchstatements in method shims
Variants§
Preferred(PreferredRuntime)
Just (a handle to) the preferred runtime
Dyn(Box<dyn DynProvider>)
Some other runtime
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Impl
impl !RefUnwindSafe for Impl
impl Send for Impl
impl Sync for Impl
impl Unpin for Impl
impl UnsafeUnpin for Impl
impl !UnwindSafe for Impl
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more