Re: [go-nuts] Timeout using Select from "Go Design Pattern"

2016-09-23 Thread ishantagarwal1986
Hi Every time you call time.After, it allocates a new time.Timer object. Morever someone in this link at last mentions that timer object does get cleaned up once the timer has fired. Also golang doc suggests that "The

Re: [go-nuts] Timeout using Select from "Go Design Pattern"

2016-09-23 Thread ishantagarwal1986
Considering what is mentioned in the video, it looks like whenever a second has gone by and a message is not returned only then the exit from loop will happen. Which means the loop may run indefinitely as well if boring function keeps on returning something or the other within a second on the

Re: [go-nuts] Timeout using Select from "Go Design Pattern"

2016-09-23 Thread Sam Whited
On Fri, Sep 23, 2016 at 9:13 AM, Sam Whited wrote: > The time.After channel isn't garbage collected until after the function > returns (when > it goes out of scope). I'm sorry, I just re-read my original email and it was very confusing; in the current code the timer is in

Re: [go-nuts] Timeout using Select from "Go Design Pattern"

2016-09-23 Thread Sam Whited
On Fri, Sep 23, 2016 at 10:00 AM, wrote: > Considering what is mentioned in the video, it looks like whenever a second > has gone by and a message is not returned only then the exit from loop will > happen. > Which means the loop may run indefinitely as well if

Re: [go-nuts] Timeout using Select from "Go Design Pattern"

2016-09-23 Thread Debraj Manna
Thanks Sam for the reply. If I get you correctly then the entire loop will run for 1 second right because after 1second then time.After will return the current time on the channel and the function will return. On Sep 23, 2016 7:43 PM, "Sam Whited" wrote: On Fri, Sep 23,

Re: [go-nuts] Timeout using Select from "Go Design Pattern"

2016-09-23 Thread Sam Whited
On Fri, Sep 23, 2016 at 6:24 AM, DM wrote: > So a timer is started for 1 second. Before 1 second is over let's say boring > writes something to channel c then case s := <- c will be executed. The > moment somthing is written on channel c the timer that was started gets

[go-nuts] Timeout using Select from "Go Design Pattern"

2016-09-23 Thread DM
I was going through the *"Go Design Pattern"* talk by Rob Pike. Can some one explain me the doubt I am having in the slide Timeout using Select . In the the video this is the location where it is