eigerco / blockstore

An IPLD blockstore capable of holding arbitrary data indexed by CID
Apache License 2.0
6 stars 8 forks source link

feature request: Consider conditionally compiling on `Send` and `Sync` bounds #2

Closed matheus23 closed 5 months ago

matheus23 commented 5 months ago

With wasm_bindgen, the JsValue and JsFuture types are !Sync.

I've seen that you've been using SendWrapper in your implementation so far, but personally would prefer solutions that don't have the potential to panic at runtime.

Here's examples for using conditional compilation for Send and Sync bounds:

oblique commented 5 months ago

Currently almost all the Rust WASM infrastructure relies on SendWrapper because multi-threading in browsers is still not well defined and everything is single-threaded. I do like your proposal but we still need to see in practice how it will affect beetswap and lumina-node. Feel free to send a PR and we will evaluate it at that time.

matheus23 commented 5 months ago

Feel free to send a PR and we will evaluate it at that time.

Will definitely do this, but only if/after #6 is merged, because #6 slightly changes the way Send bounds are applied (impl Future + Send vs. async_trait(?Send)/async_trait).