Struct wasmer_wasix::os::task::process::WasiProcess
source · pub struct WasiProcess {
pub(crate) pid: WasiProcessId,
pub(crate) module_hash: ModuleHash,
pub(crate) parent: Option<Weak<RwLock<WasiProcessInner>>>,
pub(crate) inner: LockableWasiProcessInner,
pub(crate) compute: WasiControlPlaneHandle,
pub(crate) finished: Arc<OwnedTaskStatus>,
pub(crate) waiting: Arc<AtomicU32>,
pub(crate) cpu_run_tokens: Arc<AtomicU32>,
}
Expand description
Represents a process running within the compute state TODO: fields should be private and only accessed via methods.
Fields§
§pid: WasiProcessId
Unique ID of this process
module_hash: ModuleHash
Hash of the module that this process is using
parent: Option<Weak<RwLock<WasiProcessInner>>>
List of all the children spawned from this thread
inner: LockableWasiProcessInner
The inner protected region of the process with a conditional variable that is used for coordination such as snapshots.
compute: WasiControlPlaneHandle
Reference back to the compute engine
finished: Arc<OwnedTaskStatus>
Reference to the exit code for the main thread
waiting: Arc<AtomicU32>
Number of threads waiting for children to exit
cpu_run_tokens: Arc<AtomicU32>
Number of tokens that are currently active and thus the exponential backoff of CPU is halted (as in CPU is allowed to run freely)
Implementations§
source§impl WasiProcess
impl WasiProcess
pub fn acquire_cpu_run_token(&self) -> CpuRunToken
pub fn acquire_cpu_backoff_token( &self, tasks: &Arc<dyn VirtualTaskManager>, ) -> Option<CpuBackoffToken>
source§impl WasiProcess
impl WasiProcess
pub fn new( pid: WasiProcessId, module_hash: ModuleHash, plane: WasiControlPlaneHandle, ) -> Self
pub(super) fn set_pid(&mut self, pid: WasiProcessId)
sourcepub fn pid(&self) -> WasiProcessId
pub fn pid(&self) -> WasiProcessId
Gets the process ID of this process
sourcepub fn ppid(&self) -> WasiProcessId
pub fn ppid(&self) -> WasiProcessId
Gets the process ID of the parent process
sourcepub fn lock(&self) -> MutexGuard<'_, WasiProcessInner>
pub fn lock(&self) -> MutexGuard<'_, WasiProcessInner>
Gains access to the process internals
sourcepub fn new_thread(
&self,
layout: WasiMemoryLayout,
start: ThreadStartType,
) -> Result<WasiThreadHandle, ControlPlaneError>
pub fn new_thread( &self, layout: WasiMemoryLayout, start: ThreadStartType, ) -> Result<WasiThreadHandle, ControlPlaneError>
Creates a a thread and returns it
sourcepub fn new_thread_with_id(
&self,
layout: WasiMemoryLayout,
start: ThreadStartType,
tid: WasiThreadId,
) -> Result<WasiThreadHandle, ControlPlaneError>
pub fn new_thread_with_id( &self, layout: WasiMemoryLayout, start: ThreadStartType, tid: WasiThreadId, ) -> Result<WasiThreadHandle, ControlPlaneError>
Creates a a thread and returns it
sourcepub fn get_thread(&self, tid: &WasiThreadId) -> Option<WasiThread>
pub fn get_thread(&self, tid: &WasiThreadId) -> Option<WasiThread>
Gets a reference to a particular thread
sourcepub fn signal_thread(&self, tid: &WasiThreadId, signal: Signal)
pub fn signal_thread(&self, tid: &WasiThreadId, signal: Signal)
Signals a particular thread in the process
sourcepub fn signal_process(&self, signal: Signal)
pub fn signal_process(&self, signal: Signal)
Signals all the threads in this process
sourcepub fn snapshot_and_disable_journaling(
&self,
trigger: SnapshotTrigger,
) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
pub fn snapshot_and_disable_journaling( &self, trigger: SnapshotTrigger, ) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
Takes a snapshot of the process and disables journaling returning a future that can be waited on for the snapshot to complete
Note: If you ignore the returned future the checkpoint will still occur but it will execute asynchronously
sourcepub fn snapshot(
&self,
trigger: SnapshotTrigger,
) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
pub fn snapshot( &self, trigger: SnapshotTrigger, ) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
Takes a snapshot of the process
Note: If you ignore the returned future the checkpoint will still occur but it will execute asynchronously
sourcepub fn disable_journaling_after_checkpoint(&self)
pub fn disable_journaling_after_checkpoint(&self)
Disables the journaling functionality
sourcepub fn wait_for_checkpoint(
&self,
) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
pub fn wait_for_checkpoint( &self, ) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
Wait for the checkout process to finish
sourcepub fn wait_for_checkpoint_finish(
&self,
) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
pub fn wait_for_checkpoint_finish( &self, ) -> Pin<Box<dyn Future<Output = ()> + Send + Sync>>
Wait for the checkout process to finish
sourcepub fn signal_interval(
&self,
signal: Signal,
interval: Option<Duration>,
repeat: bool,
)
pub fn signal_interval( &self, signal: Signal, interval: Option<Duration>, repeat: bool, )
Signals one of the threads every interval
sourcepub fn active_threads(&self) -> u32
pub fn active_threads(&self) -> u32
Returns the number of active threads for this process
sourcepub async fn join(&self) -> Result<ExitCode, Arc<WasiRuntimeError>>
pub async fn join(&self) -> Result<ExitCode, Arc<WasiRuntimeError>>
Waits until the process is finished.
sourcepub fn try_join(&self) -> Option<Result<ExitCode, Arc<WasiRuntimeError>>>
pub fn try_join(&self) -> Option<Result<ExitCode, Arc<WasiRuntimeError>>>
Attempts to join on the process
sourcepub async fn join_children(
&mut self,
) -> Option<Result<ExitCode, Arc<WasiRuntimeError>>>
pub async fn join_children( &mut self, ) -> Option<Result<ExitCode, Arc<WasiRuntimeError>>>
Waits for all the children to be finished
sourcepub async fn join_any_child(
&mut self,
) -> Result<Option<(WasiProcessId, ExitCode)>, Errno>
pub async fn join_any_child( &mut self, ) -> Result<Option<(WasiProcessId, ExitCode)>, Errno>
Waits for any of the children to finished
Trait Implementations§
source§impl Clone for WasiProcess
impl Clone for WasiProcess
source§fn clone(&self) -> WasiProcess
fn clone(&self) -> WasiProcess
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for WasiProcess
impl Debug for WasiProcess
source§impl SignalHandlerAbi for WasiProcess
impl SignalHandlerAbi for WasiProcess
Auto Trait Implementations§
impl Freeze for WasiProcess
impl !RefUnwindSafe for WasiProcess
impl Send for WasiProcess
impl Sync for WasiProcess
impl Unpin for WasiProcess
impl !UnwindSafe for WasiProcess
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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