4

*tries to make something elegant*

*tangles*

???

turns out converting mutexes to mpsc isn't as easy as I thought it would be 😭
also can the AIs stop sucking. they're my only source of information

Comments
  • 4
    Then read documentation instead.
  • 1
    @Ranchonyx I read that but that's not helpful cuz it's too simple
  • 0
    welp seems I can't avoid mutex

    my thing hangs sometimes though after much processing and if I switched to mpsc exclusively maybe I would find out where it's doing that. reee

    there's tokio broadcast which is mpmc but it sends data to all consumers instead of multiple consumers work down a dequeue
  • 1
    What does mpsc has to do with mutexes? I mean, if you need shared data, you probably still need mutex. Even with that. I did check the crate just now. Am I wrong?
  • 1
    @retoor since my thing hangs and mutex can lock best explanation for the hanging is the mutex

    mpsc sends from multiple producers/senders down a "stream" to be read by one consumer/receiver. but the receiver had to be mutable when it receives. which then means you'd have to wrap it in a mutex, which is mutability exclusive

    both mutex and mpsc can be used with multiple different threads (except apparently while you can duplicate mpsc senders to multiple threads you can't duplicate mpsc receivers into multiple threads so with a mpsc you'll need to wrap the receiver in a mutex)

    anyway I'm sure none of that makes sense anyway

    there's some weird atomic data types in rust that let you for example increment numbers without locking a mutable state exclusively on a value so however that does it I want it in a queue

    and I guess that's not an in-built type when surely someone has previously had a use-case for this?
  • 1
    @jestdotty But where the locks come from? Do you nest mutexes or something? Take my sodoku generators. they're massive in sharing date, most puzzles are generated and solved in a ms. To add this to statistics, every thread locks the data of the main process -> pushes data -> continues. During the mutex lock NOTHING happens besides copy of data. The preparation of the how the data should be and stuff is done before. I can lock thousands of times in a second without issue. Performance difference without lock isn't that much but it's dangerous.

    The server I'm working now doesn't use heap at all. Everything is preserved. So freaking stable. IF you have a C application good stable, it directly also feels like the most stable thing ever, because you know every detail. Valgrind says no leaks possible. Cool, it just had a few hundred concurrent connections transferring GIGABYTES. No byte left after that.
  • 0
    @retoor ye idk how it does the lock

    an idea was look into how mpsc is built and built another one but I don't wanna write infrastructure

    rust is supposed to be "know how everything works" also but they write too many words and suck at explaining anything. but it's annoyingly verbose because that was their goal
Add Comment