Re:Writing Pythonic Rust
by barsonme on Monday May 24, 2021 @04:09PM
(#27269100)
By acquiring and releasing resources. I’m not intimately familiar with Rust, so I’ll use Go as an example.
Create a one-buffered channel: `make(chan T, 1)`. To acquire, receive from the channel. If the object is in use, the receive will block (goroutine put to sleep) until it’s available. To release, send the acquired object to the channel.
Create a one-buffered channel: `make(chan T, 1)`. To acquire, receive from the channel. If the object is in use, the receive will block (goroutine put to sleep) until it’s available. To release, send the acquired object to the channel.
On a language level, no mutexes.