4 ms·
This looks awesome. I have been playing with WASM and rust, trying to get rusqlite to work with persistence, among other things. I notice that you also came to
by rklaehn 5y ago
This looks awesome. I have been playing with WASM and rust, trying to get rusqlite to work with persistence, among other things.
I notice that you also came to the conclusion that having all io async is not the way to go for rust.
How do you wrap the async js io apis so they can be used in sync rust? I have seen different approaches for this: 1. an additional service worker / thread and atomics. 2. rewrite the entire WASM in some sort of continuation passing style.
- janpaul123 5y agoWe used approach #1: https://github.com/Zaplib/zaplib/blob/7976d39775dd1642f20d8bd3e234091f27b95540/zaplib/web/task_worker.ts#L14 https://github.com/Zaplib/zaplib/blob/7976d39775dd1642f20d8b... I might write a blog post about this, since it's pretty fun / tricky stuff!
- rklaehn 5y agoYes, I also went with the 1st one. Basically the main thread sends a command to an io executor thread, and then waits on the result, which is done using atomics under the hood. See e.g. https://github.com/cloudpeers/radixdb/blob/sqlite/browser/src/sync_fs.rs#L98 https://github.com/cloudpeers/radixdb/blob/sqlite/browser/sr... Can't wait to play with zaplib. Can you also use it as just a standard library without the GUI part?