Trait wasmer_wasix::runtime::task_manager::VirtualTaskManager
source · pub trait VirtualTaskManager: Debug + Send + Sync + 'static {
// Required methods
fn build_memory(
&self,
store: &mut StoreMut<'_>,
spawn_type: SpawnType
) -> Result<Option<Memory>, WasiThreadError>;
fn sleep_now<'life0, 'async_trait>(
&'life0 self,
time: Duration
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
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: Box<dyn FnOnce(Store, Module, Option<Memory>) + Send + 'static>,
store: Store,
module: Module,
spawn_type: SpawnType
) -> Result<(), WasiThreadError>;
fn task_dedicated(
&self,
task: Box<dyn FnOnce() + Send + 'static>
) -> Result<(), WasiThreadError>;
fn thread_parallelism(&self) -> Result<usize, WasiThreadError>;
}
Expand description
An implementation of task management
Required Methods§
sourcefn build_memory(
&self,
store: &mut StoreMut<'_>,
spawn_type: SpawnType
) -> Result<Option<Memory>, WasiThreadError>
fn build_memory( &self, store: &mut StoreMut<'_>, spawn_type: SpawnType ) -> Result<Option<Memory>, WasiThreadError>
Build a new Webassembly memory.
May return None
if the memory can just be auto-constructed.
sourcefn sleep_now<'life0, 'async_trait>(
&'life0 self,
time: Duration
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn sleep_now<'life0, 'async_trait>( &'life0 self, time: Duration ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
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: Box<dyn FnOnce(Store, Module, Option<Memory>) + Send + 'static>,
store: Store,
module: Module,
spawn_type: SpawnType
) -> Result<(), WasiThreadError>
fn task_wasm( &self, task: Box<dyn FnOnce(Store, Module, Option<Memory>) + Send + 'static>, store: Store, module: Module, spawn_type: SpawnType ) -> Result<(), WasiThreadError>
Starts an asynchronous task will will run on a dedicated thread pulled from the worker pool that has a stateful thread local variable It is ok for this task to block execution and any async futures within its scope
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