LinkerShared

Struct LinkerShared 

Source
pub(in state::linker) struct LinkerShared {
    linker_state: Arc<RwLock<LinkerState>>,
    topology_coordinator: TopologyCoordinator,
    dl_operation_pending: Arc<AtomicBool>,
}
Expand description

Shared linkage and synchronization primitives for every super::super::Linker handle.

Cloning is cheap (Arc-backed locks and coordinators); clone when an instance-group handle outlives a particular stack frame but must keep talking to the same dynamic-link universe.

Fields§

§linker_state: Arc<RwLock<LinkerState>>

Global module tables, buses, … — see LinkerState.

§topology_coordinator: TopologyCoordinator

TopologyCoordinator embedded with this linker — guards topology-changing phases.

At most one active TopologyToken may exist cluster-wide while any topology mutation sequence is underway.

§dl_operation_pending: Arc<AtomicBool>

Set during LinkerShared::synchronize_link_operation so syscall paths / cooperative writers can enter LinkerShared::do_pending_link_operations_internal.

Implementations§

Source§

impl LinkerShared

Source

pub(in state::linker) fn new( linker_state: LinkerState, ) -> Self

Wraps freshly constructed LinkerState for the owning process/module tree (initially only the main super::super::Linker::new path).

Source

fn assert_exactly_one_dl_bus_subscriber(ls: &LinkerState)

Panics unless both DL buses have exactly one receiver — validates main-group bootstrap before exclusive writes (see Self::bootstrap_exclusive_write_then).

Source

pub(in state::linker) unsafe fn bootstrap_exclusive_write_then<R>( &self, f: impl FnOnce(&mut LinkerState) -> R, ) -> R

Exclusive LinkerState write for main linker bootstrap only.

§Safety

Must run only while exactly one instance group has subscribed to both DL buses (verified after the lock is taken — mismatch panics in release builds). Caller must respect instance-group / linker lock ordering used in super::super::Linker::new.

Source

pub(in state::linker) fn try_write_linker_state( &self, ) -> Result<RwLockWriteGuard<'_, LinkerState>, TryLockError<RwLockWriteGuard<'_, LinkerState>>>

Non-blocking try_write on LinkerState.

Used sparingly where blocking would recurse into the linker (stub paths, best-effort resolution). Prefer Self::write_linker_state for normal cooperative writes.

Source

pub(in state::linker) fn try_read_linker_state( &self, ) -> Result<RwLockReadGuard<'_, LinkerState>, TryLockError<RwLockReadGuard<'_, LinkerState>>>

Non-blocking try_read on LinkerState.

Source

pub(in state::linker) fn write_linker_state( &self, group_state: &mut InstanceGroupState, ctx: &mut FunctionEnvMut<'_, WasiEnv>, ) -> Result<RwLockWriteGuard<'_, LinkerState>, LinkError>

Locks LinkerState for write using repeated try_write plus cooperative draining of pending dynamic-link replay and LinkerStateWriteBackoff.

Prefer this over naked RwLock::write / blocking write() from instance-group linker paths: another OS thread might hold the write lock while follower groups rendezvous at a DL barrier waiting for this thread to run Self::do_pending_link_operations_internal.

Source

pub(in state::linker) fn acquire_topology_token( &self, group_state: &mut InstanceGroupState, store: &mut impl AsStoreMut, env: &FunctionEnv<WasiEnv>, ) -> Result<TopologyToken, LinkError>

TopologyCoordinator::try_acquire loop with LinkerStateWriteBackoff plus cooperative drains of Self::do_pending_link_operations_internal.

Lock ordering: topology must be leased before taking LinkerState for write paths that change replicated topology (spawn prepare, guarded loads, super::super::Linker::resolve_export, etc.).

prepare_for_instance_group is the motivating case — the parent attaches no new subscribers until the child finalizes while still holding this token handed across threads.

Source

pub(in state::linker) fn write_linker_state_blocking_holding_topology( &self, topology: TopologyToken, ) -> (TopologyToken, RwLockWriteGuard<'_, LinkerState>)

Blocking RwLock write once a TopologyToken is already held (spawn finalization — e.g. super::super::Linker::create_instance_group).

Returns (token, guard) — drop the guard before token to avoid extending the write critical section beyond topology decisions.

Source

pub(in state::linker) fn write_linker_state_with_topology( &self, group_state: &mut InstanceGroupState, ctx: &mut FunctionEnvMut<'_, WasiEnv>, ) -> Result<(TopologyToken, RwLockWriteGuard<'_, LinkerState>), LinkError>

Acquires topology (see Self::acquire_topology_token), then takes a blocking write lock via Self::write_linker_state_blocking_holding_topology.

Use this for paths that mutate LinkerState under the topology coordinator’s single-writer umbrella when the lease was not already taken elsewhere.

Broadcasts DlOperation op to every instance-group receiver then waits for replay.

Contracts:

  • topology must already belong to this instigating flow and was leased before exclusive access to buses / tables was acquired.
  • linker_state_write_lock guards bus broadcast invariants (try_broadcast must succeed).
  • Recoverable semantic failures are surfaced by callers; panics here are always fatal — bus capacity misuse or missed rendezvous implies we cannot reconcile groups.
  • Drops topology when done (num_groups <= 1) or after the follower completion barrier.
Source

pub(in state::linker) fn dl_operation_pending_load( &self, ordering: Ordering, ) -> bool

Peek at the cooperative-DL handshake flag dl_operation_pending with arbitrary memory ordering.

Prefer Ordering::SeqCst (fast = false in callers) whenever another thread waking from Sigwakeup must reliably observe transitions; relaxed loads are intentionally lossy — safe only when callers will retry promptly on their own syscall boundaries.

Follow half of Self::synchronize_link_operation — participates in barriers, consumes the broadcast DlOperation, and applies op to group_state under LinkerState read access.

Intended for callers that already skipped the idle fast path (cheap load of dl_operation_pending) yet still need deterministic rendezvous semantics.

§Panics

Missing receivers / malformed bus state panic — those are irrecoverable and indicate we lost synchronization with subscribers.

Trait Implementations§

Source§

impl Clone for LinkerShared

Source§

fn clone(&self) -> LinkerShared

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> Upcastable for T
where T: Any + Send + Sync + 'static,

§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,