pub trait LocalRuntimeFactory: Runtime {
type LocalMutex<T: 'static>: LocalMutexLike<T>;
type LocalNotify: LocalNotifyLike;
// Required methods
fn new_local_mutex<T: 'static>(value: T) -> Self::LocalMutex<T>;
fn new_local_notify() -> Self::LocalNotify;
}Expand description
Sibling extension of Runtime for runtimes that pin
tasks to a single core (prime’s per-core executor, embedded
runtimes with no multi-thread executor at all). Provides
non-Send primitive factories that skip the atomic synchronization
a Send-shaped primitive needs.
TokioPerCoreRuntime does NOT impl this trait because its
multi-thread runtime can move tasks across cores; the !Send
guards would be a soundness bug. Prime opts in because its
spawn_on_current_core keeps the future pinned to one thread.
Perf claim: the Local primitives use Rc<RefCell<T>> shape
without any atomic operations on the lock state. Whether this
is measurably faster than RuntimeFactory::Mutex<T> on the
uncontended fast path is a question the bench harness has to
answer; the API exists so the option can be measured (and so
callers can express the single-core constraint at the type
level).
Required Associated Types§
type LocalMutex<T: 'static>: LocalMutexLike<T>
type LocalNotify: LocalNotifyLike
Required Methods§
fn new_local_mutex<T: 'static>(value: T) -> Self::LocalMutex<T>
fn new_local_notify() -> Self::LocalNotify
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".