Mostly computer and technical stuff. Radical listener. Tries to be a good person.
#Rust #UA

  • 0 Posts
  • 5 Comments
Joined 2Y ago
cake
Cake day: Dec 20, 2022

help-circle
rss

@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.