Open wiktorwieclaw opened 1 year ago
Hi, sorry for missing this!
I think this is a great idea, a PR world be highly appreciated! If you get started, ping me in matrix and I'll give feedback early :)
I'm interested in implementing this feature.
To clarify I'd also like to work on this, I just was a bit busy last month. @0xf4lc0n we can work together on it if you wish
Sure, I'm looking forward to cooperating.
I would like to present my current solution for this problem in rtic-rs/rtic. You can view the whole code in here.
I've introduced six new structs and two traits to enhance the functionality:
Sender::send()
. By implementing the Future and Drop traits, I was able to eliminate the need for poll_fn
and dropper
functions.Receiver::recv()
.Additionally, I've introduced two traits:
I've also added tests to ensure the correctness of my implementation.
However, there are a couple of challenges I encountered:
Please feel free to review the code and provide feedback or suggestions for improvement.
I'd like to have dynamically dispatched versions of Sender and Receiver with type erased queue size.
Similar feature is already implemented in embassy_sync.
Motivation
I'm trying to implement an actor model around RTIC. Each actor is supposed to have an address that can be used to send messages to it.
Having the channel's size embedded in the Address type is inconvenient and makes some patterns impossible.
Implementation
Of course, we can't have async functions in traits, but we could work around that by manually implementing
SendFuture
andRecvFuture
types and returning them from regular functions.I'd be happy to write a PR if I get a green light, I may want to ask for some help implementing the futures as I've never done this before.