Well, while this changes the random distribution, it still violates c. c
specifically requires *deterministic* behavior in the case that multiple
communications can proceed.

I may be reading OP wrong, but from what I understand, the idea is that
this test suite (roughly) is supposed to deterministically pass:
https://play.golang.org/p/gjl-1ny1Iw (and yes, I am aware that a) this
doesn't work because we can't test for deadlocks and b) strictly speaking
it's not deterministic that other goroutines get scheduled during
time.Sleep, but you get the point).

I don't believe this to be possible currently, only using the primitives
given by the language. An implementation would basically (IMHO) need to
create their own scheduling and channel implementation. Which (IMHO) is
also the correct way to solve this, as legitimate use cases for it are a
rare edge-case that we shouldn't complicate the language for.

On Wed, Jan 25, 2017 at 5:11 PM, Jan Mercl <0xj...@gmail.com> wrote:

> On Wed, Jan 25, 2017 at 5:00 PM 'Axel Wagner' via golang-nuts <
> golang-nuts@googlegroups.com> wrote:
>
> > I don't believe the actual use case described can be mapped. From what I
> understand, the intended behavior was
> > a) put the goroutine to sleep until some communication can proceed
> > b) if exactly one communication can proceed, do it
> > c) if multiple communications can proceed, choose the one with the
> highest priority
> >
> > The suggested solutions (or any I can think of) violate at least one of
> these. They either wait busily, violating a, or they try to communicate in
> priority-order, then, as a last resort, block on any particular case,
> violating b, or they fall back to a regular select, violating c.
>
> v2: https://play.golang.org/p/lE4SpFjK_C
>
> --
>
> -j
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to