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
impl RuntimeOwner
Sourcepub fn use_foreign_events(&self, participant: &ForeignParticipant) -> Result<()>
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.
Sourcepub fn use_fe11_events(&self) -> Result<()>
pub fn use_fe11_events(&self) -> Result<()>
Restore Fe11 as the single event source after the current waiter returns.
Source§impl RuntimeOwner
impl RuntimeOwner
Sourcepub unsafe fn register_foreign<T: Send + Sync + 'static>(
&self,
owner: T,
) -> Result<ForeignParticipant>
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.
Sourcepub fn foreign_status(&self) -> Result<ForeignStatus>
pub fn foreign_status(&self) -> Result<ForeignStatus>
Inspect registered foreign ownership without querying the native module.
Sourcepub fn collect_foreign(&self) -> Result<usize>
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
impl RuntimeOwner
Sourcepub fn successor(
&self,
builder: ModuleBuilder,
) -> Result<(RuntimeOwner, Module)>
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.
Sourcepub unsafe fn attach_successor(
&self,
builder: ModuleBuilder,
initialization: ExternalInitialization,
) -> Result<(RuntimeOwner, Module)>
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.