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

Side by Side Diff: go/src/infra/libs/clock/systemclock/timer.go

Issue 1154213012: Add context-aware "time" library wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Refactored into sub-packages. 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 (c) 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 systemclock
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 }
iannucci 2015/06/02 22:19:03 var _ clock.Timer = (*systemTimer)(nil) // since
dnj 2015/06/03 00:25:28 Done.
15
16 // Implements Timer.
17 func (t *systemTimer) GetC() (c <-chan time.Time) {
18 if t.T != nil {
19 c = t.T.C
20 }
21 return
22 }
23
24 // Implements Timer.
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 // Implements Timer.
34 func (t *systemTimer) Stop() bool {
35 if t.T == nil {
36 return false
37 }
38 return t.T.Stop()
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698