Skip to main content

ProcessOwner

Struct ProcessOwner 

Source
pub struct ProcessOwner<K = ()>(/* private fields */);
Expand description

The owner of a leaked Record allocation, freeing it on drop.

It must outlive the program’s coroutine, whose frames point into the allocation: drive_owned holds it beside the coroutine and drops it afterwards, on every path.

Implementations§

Source§

impl<K> ProcessOwner<K>

Source

pub fn new(keep: K, state: HostState) -> Result<Self, Status>

Move the state and keep into a new allocation, reporting allocator exhaustion instead of aborting. Both are released if this fails.

Source

pub fn from_startup( keep: K, arguments: Vec<String>, standard_input: Option<File>, standard_output: Option<File>, standard_error: Option<File>, ) -> Result<Self, Status>

Build the host state from a program’s arguments and standard streams, then ProcessOwner::new.

Source

pub fn heap(&self) -> NonNull<Heap>

The heap of the process. It stays valid until self is dropped.

Source

pub fn state(&self) -> NonNull<HostState>

The host state of the process. It stays at this address until self is dropped.

Source

pub unsafe fn entry( &self, entry: NativeEntry, launch: Option<ProcessLaunch>, ) -> impl FnOnce() -> i32 + 'static + use<K>

The coroutine entry of the program. It holds only pointers into the allocation and the launch request, which the callee consumes before native code runs: the arguments, the streams and the startup block stay in the host state, off the coroutine stack, so a process that exits early abandons this frame without leaking (see xila_process_exit).

Without a launch the program is started like a linked one with no process capability: it gets none of the process services and cannot exit early.

§Safety

entry obeys the startup lifetime rules, fits on the coroutine stack, and returns without unwinding. It stays callable until the owner is dropped. The returned closure must be invoked at most once, and only inside a coroutine that is dropped before the owner (see drive_owned).

Source§

impl<K: 'static> ProcessOwner<K>

Source

pub fn erase(self) -> AnyProcessOwner

Erase the type of the keep-alive value. The drop behavior is unchanged.

Trait Implementations§

Source§

impl<K> Drop for ProcessOwner<K>

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§

§

impl<K> Freeze for ProcessOwner<K>

§

impl<K = ()> !RefUnwindSafe for ProcessOwner<K>

§

impl<K = ()> !Send for ProcessOwner<K>

§

impl<K = ()> !Sync for ProcessOwner<K>

§

impl<K> Unpin for ProcessOwner<K>

§

impl<K> UnsafeUnpin for ProcessOwner<K>

§

impl<K = ()> !UnwindSafe for ProcessOwner<K>

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, 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.