Giter Site home page Giter Site logo

Comments (4)

dimitri-lenkov avatar dimitri-lenkov commented on June 11, 2024 1

Found some thoughts from @Restioson on this exact issue:

#7

If you can give me some pointers in the current development branch on where to start tackling this problem I'm happy to poke and prod around even-if it requires duplication of code. I'm working on a code base that targets two WebRTC implementations: webrtc-rs and the WebIDL bindings to WebRTC that web_sys provides (but web_sys marks JsValue's as !Send).

I've ported some of my crude hand-rolled actors to xtra and like what I see (it worked perfectly with webrtc-rs), but when I tested the browser peers (using the web_sys bindings to WebRTC) things went all sideways haha.

Sorry for the spam. I really like this library so far ~ 🌹


Update: More info on !Send from another actor crate, stakker, that uses a single-threaded runtime (I'm new to Rust and finding all of this interesting lol):

https://uazu.github.io/stakker/d-whysing.html

[...] if we choose to limit ourselves to a single thread, then we can avoid those restrictions entirely and stay low-level and fast, free to use non-Send types [...]

from xtra.

thomaseizinger avatar thomaseizinger commented on June 11, 2024 1

Annoyingly, we currently have to enforce that the Actor is either Send or !Send because async fns in traits are not yet stable.

As a workaround, we use the async-trait proc macro which boxes the future into a trait object. At that point you unfortunately have to make a decision on what traits your type implements (i.e. type inference goes out the window) and this includes Send.

Once we have native async functions in traits, I believe we will just be able to have the Rust compiler infer whether the Actor is Send and this problem should be resolved.

from xtra.

Restioson avatar Restioson commented on June 11, 2024 1

Having non-Send actors was endlessly annoying trying to use xtra with GTK, but unfortunately I could not get it to work :( I had some ideas about how to maybe make it work with GATs, though, so I'll keep you posted on that! Still very experimental though.

One way forward might be to fork and remove the Sync/Send bounds everywhere. This will result in every actor being !Send, which is unacceptable for general use, but for wasm it's completely ok.

from xtra.

dimitri-lenkov avatar dimitri-lenkov commented on June 11, 2024

@thomaseizinger thank you for the reply. I went down a path last night changing everything to #[async_trait(?Send)] and removing all Send marker traits but was met with a wall of errors that I did not understand 😿 .

I keep reading that because GAT's are now stable, that async traits are closer to being here. Once they land you bet I'll re-consider this library!

I'm going to borrow some ideas from this crate in the meantime.

Bye.

from xtra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.