@@ -6,8 +6,8 @@ use crate::energy::ReducerBudget;
66use crate :: host:: instance_env:: InstanceEnv ;
77use crate :: host:: wasm_common:: module_host_actor:: { DescribeError , InitializationError } ;
88use crate :: host:: wasm_common:: * ;
9- use crate :: util:: poll_once_executor:: poll_once;
109use crate :: util:: string_from_utf8_lossy_owned;
10+ use futures_util:: FutureExt ;
1111use spacetimedb_primitives:: errno:: HOST_CALL_FAILURE ;
1212use wasmtime:: {
1313 AsContext , AsContextMut , ExternType , Instance , InstancePre , Linker , Store , TypedFunc , WasmBacktrace , WasmParams ,
@@ -94,15 +94,16 @@ const CALL_FAILURE: i32 = HOST_CALL_FAILURE.get() as i32;
9494/// Our Wasmtime is configured for `async` execution, and will panic if we use the non-async [`TypedFunc::call`].
9595/// The `async` config is necessary to allow procedures to suspend, e.g. when making HTTP calls or acquiring transactions.
9696/// However, most of the WASM we execute, incl. reducers and startup functions, should never block/yield.
97- /// Rather than crossing our fingers and trusting, we run [`TypedFunc::call_async`] in [`crate::util::poll_once_executor `],
98- /// a custom "async executor" which invokes [`std::task::Future::poll`] exactly once.
97+ /// Rather than crossing our fingers and trusting, we run [`TypedFunc::call_async`] in [`FutureExt::now_or_never `],
98+ /// an "async executor" which invokes [`std::task::Future::poll`] exactly once.
9999fn call_sync_typed_func < Args : WasmParams , Ret : WasmResults > (
100100 typed_func : & TypedFunc < Args , Ret > ,
101101 store : & mut Store < WasmInstanceEnv > ,
102102 args : Args ,
103103) -> anyhow:: Result < Ret > {
104104 let fut = typed_func. call_async ( store, args) ;
105- poll_once ( fut) . expect ( "`call_async` of supposedly synchronous WASM function returned `Poll::Pending`" )
105+ fut. now_or_never ( )
106+ . expect ( "`call_async` of supposedly synchronous WASM function returned `Poll::Pending`" )
106107}
107108
108109impl module_host_actor:: WasmInstancePre for WasmtimeModule {
@@ -113,7 +114,8 @@ impl module_host_actor::WasmInstancePre for WasmtimeModule {
113114 let mut store = Store :: new ( self . module . module ( ) . engine ( ) , env) ;
114115 let instance_fut = self . module . instantiate_async ( & mut store) ;
115116
116- let instance = poll_once ( instance_fut)
117+ let instance = instance_fut
118+ . now_or_never ( )
117119 . expect ( "`instantiate_async` did not immediately return `Ready`" )
118120 . map_err ( InitializationError :: Instantiation ) ?;
119121
0 commit comments