Open lastmjs opened 7 months ago
From the discord I have learned that promise_loop_poll
was removed in lieu of a Future integration. While that's nice for some use cases, this is making it difficult for my use case where I have a custom Futures implementation and use RefCell to access a global runtime. If I could just poll the promises manually I believe I would be able to proceed easily, but because I can't I have to somehow figure out how to get an async closure working, but using RefCells we generally must get everything to work in a non-async closure.
It would be wonderful to be able to poll manually again.
I went back in time to find the implementation body of promise_loop_poll
and added it into my fork of wasmedge-quickjs, so far it does indeed work!
#[deprecated]
pub fn promise_loop_poll(&mut self) {
unsafe {
let rt = self.rt();
let mut pctx: *mut JSContext = 0 as *mut JSContext;
loop {
let err = JS_ExecutePendingJob(rt, (&mut pctx) as *mut *mut JSContext);
if err <= 0 {
if err < 0 {
js_std_dump_error(pctx);
}
break;
}
}
}
}
I ask for this method to be put back and not removed.
Ok, I will restore it.
I see that
promise_loop_poll
is deprecated, though the examples show its usage. I am running into problems with promises, I don't see how to get them to progress. I have wasmedge-quickjs embedded in my own Rust program compiled to Wasm.Any help would be appreciated, thank you! And it would be great for those examples to show the up-to-date usage.