this post was submitted on 08 Sep 2023
44 points (90.7% liked)

Rust

5953 readers
7 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] jcbritobr@mastodon.social 0 points 1 year ago* (last edited 1 year ago) (1 children)

@sugar_in_your_tea #golang is a near perfect aproach for writing concurrency and async code, indeed, but rust already has channels in standard library. My github has a lot of concurrency code using only std library, including examples in atomics, channels, mutexes, conditional variables, etc...

https://doc.rust-lang.org/rust-by-example/std_misc/channels.html

https://github.com/jcbritobr/concprog/blob/master/src/threadpool.rs

https://github.com/jcbritobr/concprog/blob/master/src/channels.rs

Huh, it has been a while since I did async in Rust. I used Actix to build a multi-protocol game server for a toy project, and the only state staring needed went through the database.

I'll have to play with async Rust some more. I've looked through a lot of async code, and while it looks gross, I haven't actually written much myself to really get a feel for the ergonomics. For other projects, I've just used threads and mutexes, which has been plenty. The closest I've gotten was messing with GUIs, but that's been mostly GTK or IMGUI, which have their own synchronization patterns.

So maybe it's good enough as is.