Trait wasmer_wasix::runtime::task_manager::VirtualTaskManager
source · pub trait VirtualTaskManager: Debug + Send + Sync + 'static {
// Required methods
fn sleep_now(
&self,
time: Duration
) -> Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>;
fn task_shared(
&self,
task: Box<dyn FnOnce() -> Pin<Box<dyn Future<Output = ()> + Send + 'static>> + Send + 'static>
) -> Result<(), WasiThreadError>;
fn runtime(&self) -> &Handle;
fn runtime_enter<'g>(&'g self) -> Box<dyn Drop + 'g>;
fn task_wasm(&self, task: TaskWasm<'_, '_>) -> Result<(), WasiThreadError>;
fn task_dedicated(
&self,
task: Box<dyn FnOnce() + Send + 'static>
) -> Result<(), WasiThreadError>;
fn thread_parallelism(&self) -> Result<usize, WasiThreadError>;
// Provided method
fn build_memory(
&self,
store: &mut StoreMut<'_>,
spawn_type: SpawnMemoryType<'_>
) -> Result<Option<Memory>, WasiThreadError> { ... }
}
Expand description
An implementation of task management
Required Methods§
sourcefn sleep_now(
&self,
time: Duration
) -> Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>
fn sleep_now( &self, time: Duration ) -> Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>
Invokes whenever a WASM thread goes idle. In some runtimes (like singlethreaded execution environments) they will need to do asynchronous work whenever the main thread goes idle and this is the place to hook for that.
Starts an asynchronous task that will run on a shared worker pool This task must not block the execution or it could cause a deadlock
sourcefn runtime_enter<'g>(&'g self) -> Box<dyn Drop + 'g>
fn runtime_enter<'g>(&'g self) -> Box<dyn Drop + 'g>
Enters a runtime context
sourcefn task_wasm(&self, task: TaskWasm<'_, '_>) -> Result<(), WasiThreadError>
fn task_wasm(&self, task: TaskWasm<'_, '_>) -> Result<(), WasiThreadError>
Starts an WebAssembly task will will run on a dedicated thread pulled from the worker pool that has a stateful thread local variable
sourcefn task_dedicated(
&self,
task: Box<dyn FnOnce() + Send + 'static>
) -> Result<(), WasiThreadError>
fn task_dedicated( &self, task: Box<dyn FnOnce() + Send + 'static> ) -> Result<(), WasiThreadError>
Starts an asynchronous task will will run on a dedicated thread pulled from the worker pool. It is ok for this task to block execution and any async futures within its scope
sourcefn thread_parallelism(&self) -> Result<usize, WasiThreadError>
fn thread_parallelism(&self) -> Result<usize, WasiThreadError>
Returns the amount of parallelism that is possible on this platform
Provided Methods§
sourcefn build_memory(
&self,
store: &mut StoreMut<'_>,
spawn_type: SpawnMemoryType<'_>
) -> Result<Option<Memory>, WasiThreadError>
fn build_memory( &self, store: &mut StoreMut<'_>, spawn_type: SpawnMemoryType<'_> ) -> Result<Option<Memory>, WasiThreadError>
Build a new Webassembly memory.
May return None
if the memory can just be auto-constructed.