Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
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 -
retoor15933dWhat 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?
-
@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? -
retoor15933d@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. -
@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
Related Rants
*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
rant
threads