Documentation ¶
Index ¶
- func After(interval time.Duration, randomDeviation time.Duration, task func(), ...) *timingwheel.Timer
- func Cron(interval time.Duration, randomDeviation time.Duration, task func(), ...) *timingwheel.Timer
- func InitPool(size int, interval time.Duration, numSlots int)
- func TimeWheelInstance() *timingwheel.TimingWheel
- type TimeWheelPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func After ¶
func After(interval time.Duration, randomDeviation time.Duration, task func(), opts ...timingwheel.Option) *timingwheel.Timer
After wrap timingwheel.TimingWheel .AfterFunc
@param interval 间隔 @param randomDeviation 随机方差范围 interval = interval + randomDeviation*[-0.5,0.5) @param task @param opts
func Cron ¶
func Cron(interval time.Duration, randomDeviation time.Duration, task func(), opts ...timingwheel.Option) *timingwheel.Timer
Cron wrap timingwheel.TimingWheel .Cron
@param interval 间隔 @param randomDeviation 随机方差范围,interval=interval+randomDeviation*[-0.5,0.5) @param task @param opts
func InitPool ¶ added in v1.0.2
InitPool 初始化 pool
@param size 池子容量 @param interval 时间轮帧间隔 @param numSlots 时间槽数量 时间轮第一层总时长=interval*numSlots
func TimeWheelInstance ¶
func TimeWheelInstance() *timingwheel.TimingWheel
TimeWheelInstance 从 pool 里获取一个时间轮
@return *TimeWheel
Types ¶
type TimeWheelPool ¶
type TimeWheelPool struct {
// contains filtered or unexported fields
}
TimeWheelPool 时间轮池子
func NewTimeWheelPool ¶
func NewTimeWheelPool(size int, interval time.Duration, numSlots int) *TimeWheelPool
NewTimeWheelPool
@param size 池子容量 @param interval 时间轮帧间隔 @param numSlots 时间槽数量 时间轮第一层总时长=interval*numSlots @return *TimeWheelPool
func (*TimeWheelPool) Get ¶
func (tp *TimeWheelPool) Get() *timingwheel.TimingWheel
Get 顺序获取下一个时间轮
@receiver tp @return *TimeWheel
func (*TimeWheelPool) GetRandom ¶
func (tp *TimeWheelPool) GetRandom() *timingwheel.TimingWheel
GetRandom 随机获取一个时间轮
@receiver tp @return *TimeWheel
Click to show internal directories.
Click to hide internal directories.