Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: go/src/infra/libs/clock/systemtimer.go

Issue 1154213012: Add context-aware "time" library wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Removed goroutine safety from testtimer. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package clock
iannucci 2015/06/03 17:37:20 systemtimer
dnj 2015/06/03 18:21:27 (In "clock" package now).
6
7 import (
8 "time"
9 )
10
11 // A Timer implementation that uses time.Timer.
12 type systemTimer struct {
13 T *time.Timer // The underlying timer. Starts as nil, is initialized on Reset.
14 }
15
16 var _ Timer = (*systemTimer)(nil)
iannucci 2015/06/03 17:37:20 where does Timer come from? Should this be clock.T
dnj 2015/06/03 18:21:27 (In "clock" package now).
17
18 func (t *systemTimer) GetC() (c <-chan time.Time) {
iannucci 2015/06/03 17:37:20 C() see https://golang.org/doc/effective_go.html#
dnj 2015/06/03 18:21:27 (In "clock" package now).
19 if t.T != nil {
20 c = t.T.C
21 }
22 return
23 }
24
25 func (t *systemTimer) Reset(d time.Duration) bool {
26 if t.T == nil {
27 t.T = time.NewTimer(d)
28 return false
29 }
30 return t.T.Reset(d)
31 }
32
33 func (t *systemTimer) Stop() bool {
34 if t.T == nil {
35 return false
36 }
37 return t.T.Stop()
38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698