Skip to main content

LevelCore

Struct LevelCore 

Source
pub struct LevelCore { /* private fields */ }
Expand description

The core’s runtime, shared by every level of the image. Copy: each level’s thread carries the handle.

Implementations§

Source§

impl LevelCore

Source

pub unsafe fn new( runtime: ExecutorNodeRuntime, n_levels: u8, boot_level: u8, mutex: *mut c_void, lock: ExecLockFn, unlock: ExecLockFn, thread_id: ThreadIdFn, ) -> Result<Self, LevelError>

Make runtime the core’s level runtime (leaked for the image’s life).

n_levels is the image’s level count and boot_level the level of the calling thread. With more than one level, mutex must be an initialised recursive priority-inheriting mutex that lock / unlock take and give and thread_id must name the calling thread: the executor carries them so every pass releases the lock around its callbacks and the levels preempt each other on one executor.

§Safety

Called before any second thread can reach the runtime. mutex lives for the image’s life; thread_id is equal on one thread and distinct across live threads.

Source

pub unsafe fn with_runtime<R>( &self, f: impl FnOnce(&mut ExecutorNodeRuntime) -> R, ) -> R

Run f on the core’s runtime with the lock held.

§Safety

No reference to the runtime obtained here outlives f.

Source

pub unsafe fn open_level( &self, level: u8, ) -> Result<&'static mut BandWorker, LevelError>

Open level level on the calling thread: its worker (leaked with the level) attached to the executor’s arrival routing and the level made the registering one. Returns the worker the thread’s passes use.

§Safety

Called once per level, on the level’s own thread.

Source

pub unsafe fn spin_level_once( &self, worker: &mut BandWorker, timeout: Duration, ) -> SpinOnceResult

One pass of a spawned level’s worker: it parks (its waiter, the lock released) for at most timeout or until its band’s next timer or an arrival, then runs its band’s ready callbacks and (issue 2020) the ticks of the components its level registered – the executor’s enrolled ones inside the band pass, the runtime’s own after it, the lock held. Returns the pass’s counts.

§Safety

worker is the calling thread’s, from Self::open_level.

Source

pub unsafe fn into_runtime(self) -> ExecutorNodeRuntime

Issue 2016 – the teardown: take the runtime back from the levels, the executor’s lock removed, for the caller to close its session (Executor::close) and drop it. The level workers stay leaked, as they were for the image’s life, and the level count stays stated.

§Safety

Called once, on the boot level’s thread, after every other thread that reached the runtime (each level’s worker, any callback it ran) has stopped and been joined; no copy of this LevelCore is used afterwards.

Source

pub unsafe fn entry_spin_budget(&self) -> Duration

phase-521 W6 (RFC-0113 D2) – the budget a level runner passes to Self::spin_level_once / Self::spin_boot_once: the runtime’s ExecutorNodeRuntime::entry_spin_budget. Each park already ends at the level’s next deadline or on an arrival, so the budget is not a cadence; passing the tier’s period instead woke every idle level once a period. Ask it after the levels’ setup, which is what registers the components whose ticks keep the short budget.

§Safety

As Self::with_runtime.

Source

pub fn wake_all(&self)

phase-521 W6 – wake every level’s worker and the boot level, for a runner that is stopping them: a level parked on the long budget would otherwise see its stop flag only at its next deadline. Lock-free.

Source

pub unsafe fn spin_boot_once(&self, timeout: Duration) -> SpinOnceResult

One pass of the boot level: the executor’s own worker (transport, executor-wide chores), then the boot level’s components’ ticks, the lock held except around each callback.

§Safety

Called from the boot level’s thread only.

Trait Implementations§

Source§

impl Clone for LevelCore

Source§

fn clone(&self) -> LevelCore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LevelCore

Source§

impl Send for LevelCore

Source§

impl Sync for LevelCore

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.