Re:Ditch your (mut)ex, you deserve better
by gpderetta on Wednesday November 19, 2025 @06:33AM
(#45978329)
Given:
1:
2:
3:
4:
If 1 is a mutex, at which point it stops being a mutex? Note that 4 is my initial example.
[ Parent
| on HN ]
Re:Ditch your (mut)ex, you deserve better
by mgaunard on Wednesday November 19, 2025 @04:14PM
(#45985291)
it's a mutex iff it's acquiring a resource exclusively.
which you don't need to do for synchronization of coroutines since you can control in which order things are scheduled and whether that's done concurrently or not.
Re:Ditch your (mut)ex, you deserve better
by gpderetta on Thursday November 20, 2025 @04:35AM
(#45990813)
Not if you have multiple schedulers. Case in point: asio.strand or execution::on [1].
And even with one scheduler it makes sense to explicitly mark your critical sections.
Really, at the end of the day the primary purpose of a mutex is serialization of all operations on some data. The blocking behaviour is just a way to implement it.