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

Side by Side Diff: common/clock/clock.go

Issue 1679023005: Add Context cancellation to clock. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Cleanup memlock, restore old determinism, better name. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package clock 5 package clock
6 6
7 import ( 7 import (
8 "time" 8 "time"
9
10 "golang.org/x/net/context"
9 ) 11 )
10 12
11 // Clock is an interface to system time. 13 // Clock is an interface to system time.
12 // 14 //
13 // The standard clock is SystemClock, which falls through to the system time 15 // The standard clock is SystemClock, which falls through to the system time
14 // library. Another clock, FakeClock, is available to simulate time facilities 16 // library. Another clock, FakeClock, is available to simulate time facilities
15 // for testing. 17 // for testing.
16 type Clock interface { 18 type Clock interface {
17 // Returns the current time (see time.Now). 19 // Returns the current time (see time.Now).
18 Now() time.Time 20 Now() time.Time
19 » // Sleeps the current goroutine (see time.Sleep) 21
20 » Sleep(time.Duration) 22 » // Sleeps the current goroutine (see time.Sleep).
23 » //
24 » // If the supplied Context is canceled prior to the specified duration,
25 » // CancelSleep will return the Context's error. If the sleep completes
26 » // naturally, it will return nil.
27 » Sleep(context.Context, time.Duration) error
28
21 // Creates a new Timer instance, bound to this Clock. 29 // Creates a new Timer instance, bound to this Clock.
22 » NewTimer() Timer 30 » //
31 » // If the supplied Context is canceled, the timer will expire immediatel y.
32 » NewTimer(c context.Context) Timer
33
23 // Waits a duration, then sends the current time over the returned chann el. 34 // Waits a duration, then sends the current time over the returned chann el.
24 » After(time.Duration) <-chan time.Time 35 » //
36 » // If the supplied Context is canceled, the timer will expire immediatel y.
37 » After(context.Context, time.Duration) <-chan TimerResult
25 } 38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698