Documentation
¶
Overview ¶
* Copyright (c) 2021 Austin Zhai <singchia@163.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDurationOutOfRange = errors.New("duration out of range") ErrTimerNotStarted = errors.New("timer not started") ErrTimerForceClosed = errors.New("timer force closed") ErrOperationForceClosed = errors.New("operation force closed") ErrDelayOnCyclically = errors.New("cannot delay on cyclically tick") ErrCancelOnNonWait = errors.New("cannot cancel on firing or fired tick") )
Functions ¶
This section is empty.
Types ¶
type Tick ¶
type Tick interface { //To reset the data set at Timer.Time() Reset(data interface{}) error //To cancel the tick Cancel() error //Delay the tick Delay(d time.Duration) error //To get the channel called at Timer.Time(), //you will get the same channel if set, if not and handler is nil, //then a new created channel will be returned. C() <-chan *Event // Insert time InsertTime() time.Time // The tick duration original set Duration() time.Duration // Fired count Fired() int64 }
Tick that set in Timer can be required from Timer.Add()
type TickOption ¶
type TickOption func(*tickOption)
func WithChan ¶
func WithChan(C chan *Event) TickOption
func WithCyclically ¶
func WithCyclically() TickOption
func WithData ¶
func WithData(data interface{}) TickOption
func WithHandler ¶
func WithHandler(handler func(*Event)) TickOption
type Timer ¶
type Timer interface { Add(d time.Duration, opts ...TickOption) Tick // Close to close timer, // all ticks set would be discarded. Close() // Pause the timer, // all ticks won't continue after Timer.Movenon(). Pause() // Continue the paused timer. Moveon() }
type TimerOption ¶
type TimerOption func(*timerOption)
func WithOperationBufferSize ¶ added in v2.2.0
func WithOperationBufferSize(n int) TimerOption
func WithTimeInterval ¶
func WithTimeInterval(interval time.Duration) TimerOption
Click to show internal directories.
Click to hide internal directories.