FAQ
Thanks Dustin. Yeah, I missed that part. I don't really need close here.


On Friday, August 7, 2015 at 6:16:54 PM UTC-7, Dustin wrote:

Couple quick points:

* lose the default case in your for loop. You want that select statment to
block until one of the channels is ready, otherwise you have a busy loop.
Your playground code actually returns "process took too long" because of
that.

* remove the close(deltaChan) from the counter close, if you have a
concurrent call to Add() with close it will cause a panic.

* for add & get value, use a select statement and include done, otherwise
they will block indef. if they are called after Close(). I would call
close(done) instead of sending on done so that it broadcasts as well.

And yes, if you want Get() to include your call to Add() after Add
returns, then it would have to be an unbuffered channel.
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 6 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 8, '15 at 1:03a
activeAug 8, '15 at 3:18a
posts6
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase