@SuddenlyBlowGreen My experience too! 🙂
Can you use https://play.rust-lang.org/?version=stable&mode=debug&edition=2021 ?
Just remember that when you edit the code you have to make a new share link.
@SuddenlyBlowGreen
I’d need to see the whole unmangled example to fully understand it. Sure you could send a newly connected Tcp stream.
The general principle is that whatever you’d need a mutex or rwlock to coordinate &mut access to, instead just send all that update information as a message over a channel to some async task that exclusively owns the thing needing to be mutated.
Like writing to a database over a network instead of synchronizing access to a shared file.
@SuddenlyBlowGreen But you don’t need &mut to send to an mpsc channel.
That’s a big advantage of an async design !
It’s really pretty rare to need any locking.
@SuddenlyBlowGreen @brokenix I wouldn’t think you’d need an RWLock at all for that.
Just make an async task that listens on an mpsc channel and sends the data to all the tcp streams. That task can own outright the collection of outgoing streams.
@SuddenlyBlowGreen How about something like this: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5aba6de8e48ff97f30197684218d4a44
I know it barely compiles, and I haven’t tested it, but just to give the idea.