• Russ Cox's avatar
    runtime: make select fairer · 4f269d30
    Russ Cox authored
    The o+i*p approach to visiting select cases in random
    order stops being fair when there is some case that
    is never ready.  If that happens, then the case that follows
    it in the order gets more chances than the others.
    
    In general the only way to ensure fairness is to make
    all permutations equally likely.  I've done that by computing
    one explicitly.
    
    Makes the permutations correct for n >= 4 where
    previously they were broken.  For n > 12, there's not
    enough randomness to do a perfect job but this should
    still be much better than before.
    
    Fixes #1425.
    
    R=r, ken2, ejsherry
    CC=golang-dev
    https://golang.org/cl/4037043
    4f269d30
chan.c 19.6 KB