Skip to main content

RuntimeOwner

Struct RuntimeOwner 

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

Unique lifecycle owner returned by super::ModuleBuilder::open_shared.

All clients use the same initialization, budgets, session ledger, dispatch and notifications. They open distinct sessions; this does not make a native session shareable concurrently. No client can finalize the runtime.

Use Self::module for explicit global actions, including drainage and finalization. These retain their application-wide PKCS#11 scope. Dropping this owner withdraws all clients without calling C_Finalize or closing their sessions. Unproven native resources stay retained; dropping is not successful shutdown. Close explicitly before discarding the owner to release resources.

Foreign adapters enroll through register_foreign and its unsafe ownership contract. They must not bypass admission or finalize this initialization. Other processes may use the token under the native concurrency contract.

Implementations§

Source§

impl RuntimeOwner

Source

pub fn use_foreign_events(&self, participant: &ForeignParticipant) -> Result<()>

Select this participant as the sole native event source. An existing waiter must return before changing source. No native function is called.

Source

pub fn use_fe11_events(&self) -> Result<()>

Restore Fe11 as the single event source after the current waiter returns.

Source§

impl RuntimeOwner

Source

pub unsafe fn register_foreign<T: Send + Sync + 'static>( &self, owner: T, ) -> Result<ForeignParticipant>

Register a foreign adapter in this same initialization and dispatch domain. No foreign native function is invoked and no new initialization occurs.

§Safety

The owner must retain all foreign code/state required until finalization. Every foreign call and callback must use a matching runtime permit; every pending argument graph must remain owned by its registered ForeignWork. Global actions go through this RuntimeOwner. No other library destructor may finalize or unload it. Register existing sessions before distributing clients or invoking ordinary/global actions through the owner. No callback may originate outside an admitted native invocation, its registered pending work, or the coordinated lifecycle function itself. Use weak callback handles to avoid cycles through this registry. Opaque owner destructors must not call native lifecycle functions or retain strong client cycles.

Source

pub fn foreign_status(&self) -> Result<ForeignStatus>

Inspect registered foreign ownership without querying the native module.

Source

pub fn collect_foreign(&self) -> Result<usize>

Release completed foreign argument graphs and retired records outside native and local guards. Returns the number of argument graphs released. This never cancels pending work or calls the native module. Invoke this after callbacks leave when their graph could not be released at return.

Source§

impl RuntimeOwner

Source

pub fn successor( &self, builder: ModuleBuilder, ) -> Result<(RuntimeOwner, Module)>

Replace this retired generation and split its successor into one owner and one ordinary client. This owner retains only the old generation.

Source

pub unsafe fn attach_successor( &self, builder: ModuleBuilder, initialization: ExternalInitialization, ) -> Result<(RuntimeOwner, Module)>

Attach and split the application’s next initialization.

§Safety

The caller must satisfy Module::attach_successor’s contract for the new generation, including enrollment before distributing its client.

Source§

impl RuntimeOwner

Source

pub fn module(&self) -> &Module

Administrative view of this generation. Its close and drain methods remain explicit global operations; no native call is made by this getter. Contexts obtained from this view retain the owner’s administrative access.

Source

pub fn client(&self) -> Result<Module>

Create an ordinary view of the same live runtime, without Initialize, discovery or new budgets. Existing children keep their participation after their originating view is detached or dropped.

Trait Implementations§

Source§

impl Drop for RuntimeOwner

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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
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> 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> Same for T

Source§

type Output = T

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