Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Periodic ¶
Periodic executes fn on every period. Periodic returns if the context is cancelled. The underlying ticket adjusts the intervals or drops ticks to make up for slow runs of fn. If fn is active, Periodic will only return when fn has finished. The period must be greater than 0, otherwise Periodic panics.
If fn returns an Error, then the loop is stopped and the functions error is returned directly. On normal termination the contexts reported error will be reported.
func Wait ¶
Wait blocks for the configuration duration or until the passed context signal canceling. Wait return ctx.Err() if the context got cancelled early. If the duration has passed without the context being cancelled, Wait returns nil.
Example:
fmt.Printf("wait for 5 seconds...") if err := Wait(ctx, 5 * time.Second); err != nil { fmt.Printf("shutting down") return err } fmt.Println("done")
Types ¶
This section is empty.