Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(134)

Issue 2321043: code review 2321043: time: add After (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 9 months ago by adg
Modified:
14 years, 9 months ago
Reviewers:
CC:
r, rog, rsc, Sameer at Google, peterGo, iant, nigeltao_gnome, golang-dev
Visibility:
Public.

Description

time: add After Permits one to easily put a timeout in a select: select { case <-ch: // foo case <-time.After(1e6): // bar }

Patch Set 1 #

Patch Set 2 : code review 2321043: time: add Timeout #

Total comments: 1

Patch Set 3 : code review 2321043: time: add After #

Total comments: 5

Patch Set 4 : code review 2321043: time: add After #

Patch Set 5 : code review 2321043: time: add After #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+38 lines, -5 lines) Patch
M src/pkg/time/sleep.go View 1 2 3 4 1 chunk +25 lines, -5 lines 1 comment Download
M src/pkg/time/sleep_test.go View 1 2 1 chunk +13 lines, -0 lines 1 comment Download

Messages

Total messages: 40
adg
Hello r (cc: golang-dev@googlegroups.com), I'd like you to review this change.
14 years, 9 months ago (2010-10-05 03:43:24 UTC) #1
r2
I don't mind the idea but the name isn't right. Timeout describes to the example ...
14 years, 9 months ago (2010-10-05 03:59:55 UTC) #2
rog
On 5 October 2010 04:43, <adg@golang.org> wrote: > +func Timeout(ns int64) <-chan int64 { > ...
14 years, 9 months ago (2010-10-05 10:03:38 UTC) #3
rsc
i'd go with time.Delay. rog's comment about using absolute time sounds fine for the implementation ...
14 years, 9 months ago (2010-10-05 10:15:54 UTC) #4
adg
Is there an overhead to calling time.Nanoseconds() ? Should that be a concern? On 5 ...
14 years, 9 months ago (2010-10-05 10:17:35 UTC) #5
Sameer at Google
On 2010/10/05 10:15:54, rsc wrote: > i'd go with time.Delay. time.After(ns int64, f func() interface{}) ...
14 years, 9 months ago (2010-10-05 11:03:19 UTC) #6
r2
I like After too. -rob On Tuesday, October 5, 2010, <sameer@google.com> wrote: > On 2010/10/05 ...
14 years, 9 months ago (2010-10-05 11:54:39 UTC) #7
rog
On 5 October 2010 11:16, Andrew Gerrand <adg@golang.org> wrote: > Is there an overhead to ...
14 years, 9 months ago (2010-10-05 12:36:04 UTC) #8
rsc
Ian fixed time.Nanoseconds. Or if he didn't we can (but I think he did). I ...
14 years, 9 months ago (2010-10-05 13:17:41 UTC) #9
r2
On Oct 5, 2010, at 3:17 PM, Russ Cox wrote: > Ian fixed time.Nanoseconds. > ...
14 years, 9 months ago (2010-10-05 13:40:57 UTC) #10
rog
On 5 October 2010 14:40, Rob 'Commander' Pike <r@google.com> wrote: > if t is absolute ...
14 years, 9 months ago (2010-10-05 13:51:17 UTC) #11
r2
On Oct 5, 2010, at 3:51 PM, roger peppe wrote: > > > as far ...
14 years, 9 months ago (2010-10-05 13:54:46 UTC) #12
rog
On 5 October 2010 14:54, Rob 'Commander' Pike <r@google.com> wrote: > > On Oct 5, ...
14 years, 9 months ago (2010-10-05 14:05:04 UTC) #13
rog
On 5 October 2010 14:17, Russ Cox <rsc@golang.org> wrote: > Ian fixed time.Nanoseconds. > Or ...
14 years, 9 months ago (2010-10-05 14:18:50 UTC) #14
peterGo
Roger, > > Ian fixed time.Nanoseconds. > > Or if he didn't we can (but ...
14 years, 9 months ago (2010-10-05 14:40:16 UTC) #15
rog
ah, linux only. assuming that the fix would have been applied universally, i only looked ...
14 years, 9 months ago (2010-10-05 14:46:25 UTC) #16
iant2
roger peppe <rogpeppe@gmail.com> writes: > On 5 October 2010 14:17, Russ Cox <rsc@golang.org> wrote: >> ...
14 years, 9 months ago (2010-10-05 15:09:16 UTC) #17
rog
On 5 October 2010 16:09, Ian Lance Taylor <iant@google.com> wrote: > roger peppe <rogpeppe@gmail.com> writes: ...
14 years, 9 months ago (2010-10-05 16:39:20 UTC) #18
nigeltao_gnome
On 5 October 2010 23:36, roger peppe <rogpeppe@gmail.com> wrote: > when i've needed a timeout ...
14 years, 9 months ago (2010-10-06 01:17:26 UTC) #19
Sameer at Google
On 2010/10/05 14:05:04, rog wrote: > On 5 October 2010 14:54, Rob 'Commander' Pike <mailto:r@google.com> ...
14 years, 9 months ago (2010-10-06 02:24:45 UTC) #20
adg
Hello r, r2, rog, rsc, sameer1, PeterGo, iant2, nigeltao_gnome (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 9 months ago (2010-10-06 02:28:30 UTC) #21
Sameer at Google
This interface works for my use cases. http://codereview.appspot.com/2321043/diff/20001/src/pkg/time/sleep_test.go File src/pkg/time/sleep_test.go (right): http://codereview.appspot.com/2321043/diff/20001/src/pkg/time/sleep_test.go#newcode32 src/pkg/time/sleep_test.go:32: <-ch In ...
14 years, 9 months ago (2010-10-06 02:36:02 UTC) #22
adg
On 6 October 2010 13:36, <sameer@google.com> wrote: > http://codereview.appspot.com/2321043/diff/20001/src/pkg/time/sleep_test.go#newcode32 > src/pkg/time/sleep_test.go:32: <-ch > In addition ...
14 years, 9 months ago (2010-10-06 03:49:44 UTC) #23
r
i remain nervous about how it will be used but we can continue that discussion ...
14 years, 9 months ago (2010-10-06 06:02:31 UTC) #24
rog
http://codereview.appspot.com/2321043/diff/24001/src/pkg/time/sleep.go File src/pkg/time/sleep.go (right): http://codereview.appspot.com/2321043/diff/24001/src/pkg/time/sleep.go#newcode28 src/pkg/time/sleep.go:28: // on the returned channel. i think it would ...
14 years, 9 months ago (2010-10-06 10:07:55 UTC) #25
rsc1
http://codereview.appspot.com/2321043/diff/24001/src/pkg/time/sleep.go File src/pkg/time/sleep.go (right): http://codereview.appspot.com/2321043/diff/24001/src/pkg/time/sleep.go#newcode29 src/pkg/time/sleep.go:29: func After(ns int64) <-chan int64 { After is a ...
14 years, 9 months ago (2010-10-06 10:19:35 UTC) #26
r2
On Oct 6, 2010, at 12:19 PM, rsc@google.com wrote: > > http://codereview.appspot.com/2321043/diff/24001/src/pkg/time/sleep.go > File src/pkg/time/sleep.go ...
14 years, 9 months ago (2010-10-06 10:25:09 UTC) #27
r2
On Oct 6, 2010, at 12:25 PM, Rob 'Commander' Pike wrote: > > On Oct ...
14 years, 9 months ago (2010-10-06 10:26:42 UTC) #28
adg
On 6 October 2010 21:19, <rsc@google.com> wrote: > http://codereview.appspot.com/2321043/diff/24001/src/pkg/time/sleep.go#newcode29 > src/pkg/time/sleep.go:29: func After(ns int64) <-chan ...
14 years, 9 months ago (2010-10-06 10:28:46 UTC) #29
rsc
okay, After is fine
14 years, 9 months ago (2010-10-06 10:34:55 UTC) #30
rog
> that's also an argument against rog's complaint about absolute/relative > result. > -rob really? ...
14 years, 9 months ago (2010-10-06 10:52:13 UTC) #31
Sameer at Google
On Wed, Oct 6, 2010 at 6:52 AM, roger peppe <rogpeppe@gmail.com> wrote: > > that's ...
14 years, 9 months ago (2010-10-06 12:38:55 UTC) #32
rog
On 6 October 2010 13:38, Sameer Ajmani <sameer@google.com> wrote: >> using an absolute time means ...
14 years, 9 months ago (2010-10-06 13:11:10 UTC) #33
Sameer at Google
On Wed, Oct 6, 2010 at 9:11 AM, roger peppe <rogpeppe@gmail.com> wrote: > On 6 ...
14 years, 9 months ago (2010-10-06 14:29:07 UTC) #34
rsc
This is turning into a bikeshed discussion. Let's cut it off at func After(t int64) ...
14 years, 9 months ago (2010-10-06 14:34:39 UTC) #35
rog
On 6 October 2010 15:34, Russ Cox <rsc@golang.org> wrote: > This is turning into a ...
14 years, 9 months ago (2010-10-06 15:18:54 UTC) #36
rsc
On Wed, Oct 6, 2010 at 11:18, roger peppe <rogpeppe@gmail.com> wrote: > On 6 October ...
14 years, 9 months ago (2010-10-06 15:20:30 UTC) #37
adg
Hello r, rog, rsc, sameer1, PeterGo, iant2, nigeltao_gnome, r2 (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 9 months ago (2010-10-07 00:19:56 UTC) #38
rsc1
LGTM http://codereview.appspot.com/2321043/diff/38001/src/pkg/time/sleep.go File src/pkg/time/sleep.go (right): http://codereview.appspot.com/2321043/diff/38001/src/pkg/time/sleep.go#newcode13 src/pkg/time/sleep.go:13: // Higher resolution sleeping may be provided by ...
14 years, 9 months ago (2010-10-07 07:16:24 UTC) #39
adg
14 years, 9 months ago (2010-10-11 02:45:38 UTC) #40
*** Submitted as http://code.google.com/p/go/source/detail?r=049629072837 ***

time: add After

Permits one to easily put a timeout in a select:

select {
case <-ch:
	// foo
case <-time.After(1e6):
	// bar
}

R=r, rog, rsc, sameer1, PeterGo, iant, nigeltao_gnome
CC=golang-dev
http://codereview.appspot.com/2321043

Committer: Andrew Gerrand <adg@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b