Documentation
¶
Overview ¶
Package challengetimer measures active solving time, excluding pauses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidState indicates an operation outside its allowed lifecycle. ErrInvalidState = errors.New("challengetimer: invalid state") // ErrInvalidReason indicates an undefined pause reason. ErrInvalidReason = errors.New("challengetimer: invalid pause reason") )
Functions ¶
This section is empty.
Types ¶
type PauseReason ¶
type PauseReason string
PauseReason identifies an independent reason to exclude time.
const ( ReasonManual PauseReason = "manual" ReasonHidden PauseReason = "hidden" ReasonQuery PauseReason = "query" ReasonPlayback PauseReason = "playback" )
type Snapshot ¶
type Snapshot struct {
State State
ActiveMillis int64
Hints int
Retries int
Assisted bool
PauseReasons []PauseReason
}
Snapshot is an independent view of a timer at one instant.
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer is safe for concurrent use. Create one with New; do not copy it. The supplied clock runs under the timer's lock and must not call its methods.
func (*Timer) Finish ¶
Finish freezes elapsed time and counters, clearing all pause reasons. Repeated calls return the same result without observing the clock.
func (*Timer) Pause ¶
func (t *Timer) Pause(reason PauseReason) error
Pause adds a reason to pause. Adding an existing reason is idempotent.
func (*Timer) Reset ¶
func (t *Timer) Reset()
Reset restores the ready state and clears the clock epoch and all counters.
func (*Timer) Resume ¶
func (t *Timer) Resume(reason PauseReason) error
Resume removes a pause reason. Removing an absent reason is idempotent.