| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package clock | 5 package clock |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "time" | 8 "time" |
| 9 | 9 |
| 10 "golang.org/x/net/context" | 10 "golang.org/x/net/context" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // NewTimer calls Clock.NewTimer on the Clock instance stored in the supplied | 53 // NewTimer calls Clock.NewTimer on the Clock instance stored in the supplied |
| 54 // Context. | 54 // Context. |
| 55 func NewTimer(ctx context.Context) Timer { | 55 func NewTimer(ctx context.Context) Timer { |
| 56 return Get(ctx).NewTimer(ctx) | 56 return Get(ctx).NewTimer(ctx) |
| 57 } | 57 } |
| 58 | 58 |
| 59 // After calls Clock.After on the Clock instance stored in the supplied Context. | 59 // After calls Clock.After on the Clock instance stored in the supplied Context. |
| 60 func After(ctx context.Context, d time.Duration) <-chan TimerResult { | 60 func After(ctx context.Context, d time.Duration) <-chan TimerResult { |
| 61 return Get(ctx).After(ctx, d) | 61 return Get(ctx).After(ctx, d) |
| 62 } | 62 } |
| 63 |
| 64 // Since is an equivalent of time.Since. |
| 65 func Since(ctx context.Context, t time.Time) time.Duration { |
| 66 return Now(ctx).Sub(t) |
| 67 } |
| OLD | NEW |