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

Unified Diff: common/clock/timer.go

Issue 1679023005: Add Context cancellation to clock. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: More test coverage, cleanup, consolidation. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: common/clock/timer.go
diff --git a/common/clock/timer.go b/common/clock/timer.go
index aa03c383dda4f710b8c1745d62fca5d645a9f1c8..950c3ca1900029b835aa219648565b7790551e60 100644
--- a/common/clock/timer.go
+++ b/common/clock/timer.go
@@ -13,9 +13,8 @@ import (
// A Timer is instantiated from a Clock instance and started via its Reset()
// method.
type Timer interface {
- // GetC returns the underlying timer's channel, or nil if the timer is no
- // running.
- GetC() <-chan time.Time
+ // GetC returns the underlying timer's channel.
iannucci 2016/02/10 22:30:28 doc behavior with Reset and Stop
dnj (Google) 2016/02/11 01:26:55 Done.
+ GetC() <-chan TimerResult
// Reset configures the timer to expire after a specified duration.
//
@@ -29,3 +28,16 @@ type Timer interface {
// If the timer is active, it will be stopped and this method will return true.
Stop() bool
}
+
+// TimerResult is the result fo a timer operation.
iannucci 2016/02/10 22:30:28 fo'
dnj (Google) 2016/02/11 01:26:55 Done.
+//
+// If the timer operation completed successfully, the embedded time.Time will be
+// set to the time when the timer triggered. If the timer was prematurely
+// terminated, Err will be non-nil.
iannucci 2016/02/10 22:30:28 time will be the time when the result was generate
dnj (Google) 2016/02/11 01:26:55 Done.
+type TimerResult struct {
+ time.Time
+
+ // Err, if not nil, indicates that After did not finish naturally and contains
+ // the reason why.
+ Err error
+}

Powered by Google App Engine
This is Rietveld 408576698