Documentation
¶
Overview ¶
Package clock provides clocks, timers and timing helpers for network I/O.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Past = time.Unix(1, 0)
Past is a deadline long passed, which interrupts blocked I/O.
var RealEpoch = NewEpoch(nil)
RealEpoch is the epoch of the system clock that components without a clock of their own share; it is the one time base of activity tracking on the system clock.
Functions ¶
Types ¶
type Backoff ¶
type Backoff struct {
// contains filtered or unexported fields
}
Backoff spaces out the retries of a loop whose calls fail, such as the reads of a listener's socket or an Accept: the first failure is retried at once, as a single error such as an ICMP report or an aborted connection concerns that call alone, and failures that persist are retried with a delay that doubles from 1ms up to 1s. Its zero value is ready.
type Deadline ¶
type Deadline struct {
// contains filtered or unexported fields
}
Deadline is a resettable deadline whose expiry closes a channel, as in net.Pipe. Its zero value is not usable; see MakeDeadline.
func (*Deadline) Set ¶
Set makes the deadline expire at t, or never for the zero t. A wait on the channel of an earlier Wait goes on unless t has passed.
type Epoch ¶
type Epoch struct {
// contains filtered or unexported fields
}
Epoch tells the time of a clock as nanoseconds since the clock's time when the Epoch was made, for activity tracking in atomics. Each component takes the epoch of the clock it is given, so that a clock of any time, such as a fake one at the zero time, counts right, and a step of the system's wall clock neither stretches nor cuts an idle period.
func NewEpoch ¶
NewEpoch returns the epoch of c, or of the system clock when c is nil, at its time now.
type Idle ¶
type Idle struct {
// contains filtered or unexported fields
}
Idle runs a callback once activity has stopped for a given duration. After Init, its other methods are safe to call concurrently.
func (*Idle) BeginWait ¶
func (i *Idle) BeginWait()
BeginWait begins an operation during which the timer must not expire.
func (*Idle) End ¶
func (i *Idle) End()
End disarms the timer and prevents Start from arming it again. A callback that has already expired may still run.
func (*Idle) EndWait ¶
func (i *Idle) EndWait()
EndWait ends one operation started by BeginWait and records activity.
func (*Idle) Init ¶
Init sets up a zero Idle with timeout d, which must be positive. Call Start to arm it.