HackerTrans
トップ新着トレンドコメント過去質問紹介求人

sethvargo

no profile record

投稿

Resourcely raises $8M seed round

techcrunch.com
3 ポイント·投稿者 sethvargo·4 年前·2 コメント

Perforce acquires Puppet

techcrunch.com
2 ポイント·投稿者 sethvargo·4 年前·1 コメント

Freenode Power to the People on Blockchain?

freenode.net
8 ポイント·投稿者 sethvargo·5 年前·6 コメント

コメント

sethvargo
·4 年前·議論
This is awesome - congratulations to the team on this raise. Very well-deserved :)
sethvargo
·4 年前·議論
The context was introduced by the commenter. The original post does not use contexts. In general, there's a pretty common set of patterns in which multiple goroutines are writing data to different channels, and you need to ensure the data from those channels are processed with some level of priority.
sethvargo
·4 年前·議論
Also, this isn't semantically correct. In order to ensure that `conditionaA` is _always_ preferred over `conditionB`, you must also check if `conditionA` has received a value inside of `conditionB`:

    select {
    case a := <-conditionA:
        return a
    default:
    }
    select {
    case b := <-conditionB:
      case a := <-conditionA:
          return a
      default:

      return b
    default:
    }
sethvargo
·4 年前·議論
Right, which is noted in the post. That verbosity is, well, verbose. I generally need this in 20% of things I write.
sethvargo
·4 年前·議論
It really doesn't though. It handles the case where the context might have expired or be cancelled, but there's still a race when entering the select between the ctx.Done() and reading from thingCh. You may end up processing one additional unit of work. In situations where the exit condition is channel-based, this won't work.

Additionally, this would only work if you had one predominant condition and that condition was context-based. If you have multiple ordered conditions upon which you want to exit, I can't think of how you'd express that as a range.
sethvargo
·4 年前·議論
How would you fix that code?