Meepso
Meepso3mo ago

Async Unsafe Callback?

Is it possible to create a unsafe callback on a async function? I need the native program to wait for a response from async function before continuing!
2 Replies
Meepso
MeepsoOP3mo ago
const cb = new Deno.UnsafeCallback(
{
parameters: ["pointer"],
result: "i32"
} as const,
async (L: Deno.PointerValue) => {


}

)
const cb = new Deno.UnsafeCallback(
{
parameters: ["pointer"],
result: "i32"
} as const,
async (L: Deno.PointerValue) => {


}

)
Somthing like this!
AapoAlas
AapoAlas3mo ago
No, this is not possible as it would (in the general case) require cooperation from the caller. The only case when this would be possible without cooperation from the caller is when the caller performs this callback from a foreign thread: In that case we can block that foreign thread while we perform the asynchronous work on the main thread. But if the exact same call is performed on the main thread, there is no way to (unilaterally) block the main thread for the caller while still using the main thread to perform the asynchronous JavaScript work.

Did you find this page helpful?