run_in_dummy_executor isnt unsafe, its just a bad idea
This commit is contained in:
@@ -110,5 +110,5 @@ where
|
||||
Fut: Future<Output = Result<T, Error>>,
|
||||
T: Send + 'static,
|
||||
{
|
||||
tokio::task::block_in_place(move || unsafe { wiggle::run_in_dummy_executor(f()) })
|
||||
tokio::task::block_in_place(move || wiggle::run_in_dummy_executor(f()))
|
||||
}
|
||||
|
||||
@@ -954,7 +954,7 @@ impl From<GuestError> for Trap {
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn run_in_dummy_executor<F: std::future::Future>(future: F) -> F::Output {
|
||||
pub fn run_in_dummy_executor<F: std::future::Future>(future: F) -> F::Output {
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ fn generate_func(
|
||||
let #name_ident = wasmtime::Func::wrap(
|
||||
store,
|
||||
move |caller: wasmtime::Caller #(, #arg_decls)*| -> Result<#ret_ty, wasmtime::Trap> {
|
||||
unsafe { #rt::run_in_dummy_executor(Self::#fn_ident(&caller, &mut my_ctx.borrow_mut() #(, #arg_names)*)) }
|
||||
#rt::run_in_dummy_executor(Self::#fn_ident(&caller, &mut my_ctx.borrow_mut() #(, #arg_names)*))
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -372,7 +372,7 @@ fn generate_func(
|
||||
.store()
|
||||
.get::<std::rc::Rc<std::cell::RefCell<#ctx_type>>>()
|
||||
.ok_or_else(|| wasmtime::Trap::new("context is missing in the store"))?;
|
||||
unsafe { #rt::run_in_dummy_executor(Self::#fn_ident(&caller, &mut ctx.borrow_mut() #(, #arg_names)*)) }
|
||||
#rt::run_in_dummy_executor(Self::#fn_ident(&caller, &mut ctx.borrow_mut() #(, #arg_names)*))
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user