Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface { // Run runs the action, possibly to completion. // The parameter says for how long the action is allowed to run. // // The returned status says if the action has completed. // It also says how much time is left after it has run. Run(atMost time.Duration) Status }
An Action is a process stretched out in time.
func NoAction ¶
func NoAction() Action
NoAction returns an action that completes instantly.
Running the returned action has no side-effects.
type Countdown ¶
type Countdown struct {
// contains filtered or unexported fields
}
A Countdown tracks progress towards reaching a numerical goal. The zero value is a completed countdown with a goal of 0.
func (*Countdown) Action ¶
Action creates an action that makes the countdown progress run. The countdown completes when the action does.
func (*Countdown) CountDown ¶
CountDown tracks progress being made towards a countdown. The countdown gets closer to completion with bigger arguments.
func (Countdown) Progress ¶
Progress says how far along the countdown is. The value ranges from 0 (not started) to 1 (completed).
func (*Countdown) ResetTarget ¶
ResetTarget sets a new target value and resets all progress made.
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
An Status says whether an action completed. It also says how much time is left after running it.
func Done ¶
Done creates an action status indicating that an action has completed.
The timeLeft should be the time the action did not use up. As a special case, there will be no time left when the argument is negative.
func Interrupted ¶
Interrupted creates an action status saying that the action was interrupted.
The timeLeft should be the time the action did not use up. As a special case, there will be no time left when the argument is negative.
func Paused ¶
func Paused() Status
Paused creates an action status indicating that an action needs more time to complete.
func (Status) HasTimeLeft ¶
HasTimeLeft says whether there is time left after running an action.
func (Status) Interrupted ¶
Interrupted says whether the action was interrupted.