pub(crate) struct ContextSwitchingEnvironment {
inner: Arc<ContextSwitchingEnvironmentInner>,
}Expand description
The context-switching environment represents all state for WASIX context-switching on a single host thread.
Fields§
§inner: Arc<ContextSwitchingEnvironmentInner>Implementations§
Source§impl ContextSwitchingEnvironment
impl ContextSwitchingEnvironment
fn new(spawner: ThreadLocalSpawner) -> Self
Sourcepub(crate) fn run_main_context(
ctx: &WasiFunctionEnv,
store: Store,
entrypoint: Function,
params: Vec<Value>,
) -> (Store, Result<Box<[Value]>, RuntimeError>)
pub(crate) fn run_main_context( ctx: &WasiFunctionEnv, store: Store, entrypoint: Function, params: Vec<Value>, ) -> (Store, Result<Box<[Value]>, RuntimeError>)
Run the main context function in a context-switching environment
This call blocks until the entrypoint returns or traps
Sourcepub(crate) fn active_context_id(&self) -> u64
pub(crate) fn active_context_id(&self) -> u64
Get the ID of the currently active context
Sourcepub(crate) fn main_context_id(&self) -> u64
pub(crate) fn main_context_id(&self) -> u64
Get the id of the main context (0)
pub(crate) fn destroy_context(&self, target_context_id: &u64) -> bool
Sourcepub(crate) fn switch_context(
&self,
target_context_id: u64,
) -> Result<impl Future<Output = Result<(), RuntimeError>> + Send + Sync + use<> + 'static, ContextSwitchError>
pub(crate) fn switch_context( &self, target_context_id: u64, ) -> Result<impl Future<Output = Result<(), RuntimeError>> + Send + Sync + use<> + 'static, ContextSwitchError>
Unblock the target context and suspend own context
If this function succeeds, you MUST await the returned future
Sourcepub(crate) fn create_context<F>(&self, entrypoint: F) -> u64
pub(crate) fn create_context<F>(&self, entrypoint: F) -> u64
Create a new context and spawn it onto the thread-local executor
The entrypoint function is called when the context is unblocked for the first time
If entrypoint returns, it must be a RuntimeError, as it is not allowed to return normally.
If the RuntimeError is a ContextCanceled, the context will just exit silently.
Otherwise, the error will be propagated to the main context.
If the context is cancelled before it is unblocked, the entrypoint will not be called
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContextSwitchingEnvironment
impl !RefUnwindSafe for ContextSwitchingEnvironment
impl Send for ContextSwitchingEnvironment
impl Sync for ContextSwitchingEnvironment
impl Unpin for ContextSwitchingEnvironment
impl !UnwindSafe for ContextSwitchingEnvironment
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
§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§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read more