Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
Grammar: clock.go
Browse files Browse the repository at this point in the history
* The mock clock can also be sent backwards, not just forward, but in all cases only when requested programmatically.
* spelling
* possessive vs contractions
* possessive vs plural
* that vs articles (this also is more consistent w/ a later instance in this file)
  • Loading branch information
jsoref authored May 10, 2020
1 parent d259fcd commit 8cd1c9d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// Clock represents an interface to the functions in the standard library time
// package. Two implementations are available in the clock package. The first
// is a real-time clock which simply wraps the time package's functions. The
// second is a mock clock which will only make forward progress when
// second is a mock clock which will only change when
// programmatically adjusted.
type Clock interface {
After(d time.Duration) <-chan time.Time
Expand Down Expand Up @@ -54,7 +54,7 @@ func (c *clock) Timer(d time.Duration) *Timer {
return &Timer{C: t.C, timer: t}
}

// Mock represents a mock clock that only moves forward programmically.
// Mock represents a mock clock that only moves forward programmatically.
// It can be preferable to a real-time clock when testing time-based functionality.
type Mock struct {
mu sync.Mutex
Expand All @@ -68,7 +68,7 @@ func NewMock() *Mock {
return &Mock{now: time.Unix(0, 0)}
}

// Add moves the current time of the mock clock forward by the duration.
// Add moves the current time of the mock clock forward by the specified duration.
// This should only be called from a single goroutine at a time.
func (m *Mock) Add(d time.Duration) {
// Calculate the final current time.
Expand All @@ -86,7 +86,7 @@ func (m *Mock) Add(d time.Duration) {
m.now = t
m.mu.Unlock()

// Give a small buffer to make sure the other goroutines get handled.
// Give a small buffer to make sure that other goroutines get handled.
gosched()
}

Expand All @@ -105,13 +105,13 @@ func (m *Mock) Set(t time.Time) {
m.now = t
m.mu.Unlock()

// Give a small buffer to make sure the other goroutines get handled.
// Give a small buffer to make sure that other goroutines get handled.
gosched()
}

// runNextTimer executes the next timer in chronological order and moves the
// current time to the timer's next tick time. The next time is not executed if
// it's next time if after the max time. Returns true if a timer is executed.
// its next time is after the max time. Returns true if a timer was executed.
func (m *Mock) runNextTimer(max time.Time) bool {
m.mu.Lock()

Expand Down Expand Up @@ -161,7 +161,7 @@ func (m *Mock) Now() time.Time {
return m.now
}

// Since returns time since the mock clocks wall time.
// Since returns time since the mock clock's wall time.
func (m *Mock) Since(t time.Time) time.Duration {
return m.Now().Sub(t)
}
Expand Down

0 comments on commit 8cd1c9d

Please sign in to comment.