]> Cypherpunks repositories - gostls13.git/commit
runtime: add a select test
authorDmitry Vyukov <dvyukov@google.com>
Fri, 13 Mar 2015 10:37:57 +0000 (13:37 +0300)
committerDmitry Vyukov <dvyukov@google.com>
Wed, 18 Mar 2015 08:57:30 +0000 (08:57 +0000)
commitfcb895feef1c9214f9cb633b5a0fa4dc8f46af9e
tree954038131b8667899c76898a130ed8489c556381
parentecd630de6dd2e5285f18c650207b5c84649402db
runtime: add a select test

One of my earlier versions of finer-grained select locking
failed on this test. If you just naively lock and check channels
one-by-one, it is possible that you skip over ready channels.
Consider that initially c1 is ready and c2 is not. Select checks c2.
Then another goroutine makes c1 not ready and c2 ready (in that order).
Then select checks c1, concludes that no channels are ready and
executes the default case. But there was no point in time when
no channel is ready and so default case must not be executed.

Change-Id: I3594bf1f36cfb120be65e2474794f0562aebcbbd
Reviewed-on: https://go-review.googlesource.com/7550
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/chan_test.go