4 ms·
> Not vice versa (the current design). select { case: <-chan1_whichIWantToCheckFirst default: } select { case: <-chan2_whichI
by usrbinbash 5y ago
> Not vice versa (the current design).
select {
case: <-chan1_whichIWantToCheckFirst
default:
}
select {
case: <-chan2_whichItreatTheSameAsChan3
case: 0xFF ->chan3_whichItreatTheSameAsChan2
}
- tapirl 5y agoYes, as I have mentioned, there is performance loss, comparing to select { case: <-chan2_whichItreatTheSameAsChan3 // a higher priority case: 0xFF ->chan3_whichItreatTheSameAsChan2 }
- usrbinbash 5y agoThe real usecases where I need deterministic select, are so few that a small performance loss doesn't matter to me.
- tapirl 5y agoSometimes, it is not related to performance loss, it is related to implementation cleanness and complexity.
- usrbinbash 5y agoA separate `select` with empty `default` is about as simple and clean as it gets. It is easy to read, easy to reason about, and, most importantly, conveys the intention of the code perfectly.
- morelisp 5y ago1) Is there really a performance loss compared to if select was deterministic? 2) What in the world do you need such code for?
- tapirl 5y ago1) surely. 2) just read: https://groups.google.com/g/golang-nuts/c/SXsgdpRK-mE/m/CT7UjJ3aBAAJ https://groups.google.com/g/golang-nuts/c/ZrVIhHCrR9o https://groups.google.com/g/golang-nuts/c/lEKehHH7kZY/m/SRmCtXDZAAAJ