Comments (4)
Found some thoughts from @Restioson on this exact issue:
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.
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.
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.
@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)
- Way to mark time spent in queue and handler as follows_from request span HOT 4
- Have `Error::Disconnected` contain the actor name HOT 8
- Document features of `Context::stop_all` HOT 7
- Switch `WaitingSender` implementation to a oneshot channel implementation
- Re-organise cargo workspace
- trait for actors handling multiple message types HOT 4
- Actor with a CPU-bound task HOT 8
- wait for actor to finish processing entire mailbox HOT 10
- Review changelog and sort by priority HOT 2
- `as_either` for `MessageChannel`? HOT 3
- See if we can simplify `TickFuture` HOT 4
- Switch to IntoFuture trait instead of modifying SendFuture
- Feature Request: relax return type in into sink HOT 2
- Receiver<M> support HOT 7
- Context::notify_later replacement examples HOT 6
- Should we still recommend `spaad` in the README? HOT 3
- Experiment with nightly async fn in traits
- Atomicity of handlers HOT 2
- Actor persistence and journaling HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xtra.