-
-
Notifications
You must be signed in to change notification settings - Fork 50
Description
For the async API functions in wgpu, we currently offer two options: busy-wait for it, or async-wait for it.
In JS, an async function returns a promise, and this offers a 3d option: to provide a callback that is called when the promise resolves. I had completely overlooked this option. It's interesting, because its an option that works in sync (not-async) code, and can be made to work the same way in Python and JS/Pyodide.
I probably need to think about this more, also how this plays with rendercanvas and pygfx, but what I currently think would be a good plan is to have all the async API functions return a Promise-like object, which can then be used to:
promise.busy_wait()
- Python only, for code that does not care waiting a bitawait promise
- works in Python and JSpromise.then(callback)
- Python and JS
(we already have an object that does the first two things, but it's used internally (not public) and called WgpuAwaitable
)