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
unsafe
insidedowncast_value
. match
statements 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 !UnwindSafe for Impl
Blanket Implementations§
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