ticker

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

README

ticker

Helpers to process system ticks

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() uint64

Get return global tick counter

func Reset

func Reset()

Reset reset ticker

func Tick

func Tick(_ context.Context)

Tick increase global tick counter

Types

type ExecuteWithDelay

type ExecuteWithDelay struct {
	// contains filtered or unexported fields
}

ExecuteWithDelay execute method with delay

func NewExecuteWithDelay

func NewExecuteWithDelay() *ExecuteWithDelay

NewExecuteWithDelay return new execute in delay

func (*ExecuteWithDelay) IsActive

func (e *ExecuteWithDelay) IsActive() bool

IsActive return true if active

func (*ExecuteWithDelay) Start

func (e *ExecuteWithDelay) Start(ctx context.Context, h func(ctx context.Context), d time.Duration)

Start start timer

func (*ExecuteWithDelay) Stop

func (e *ExecuteWithDelay) Stop() bool

Stop stop executing

type Handler

type Handler interface {
	Tick(ctx context.Context)
	GetID() uint64
}

Handler describe tick handler

type TickHandler

type TickHandler struct {
	// contains filtered or unexported fields
}

TickHandler contains handler and interval

func NewTickHandler

func NewTickHandler(ctx context.Context, interval time.Duration, handler Handler) *TickHandler

NewTickHandler return new tick handler

type TickManager

type TickManager struct {
	// contains filtered or unexported fields
}

TickManager describe TickManager

func NewTickManager

func NewTickManager() *TickManager

NewTickManager return tick manager

func (*TickManager) Add

func (t *TickManager) Add(h *TickHandler) uint64

Add add tick handler

func (*TickManager) CountTicksInProgress

func (t *TickManager) CountTicksInProgress() int32

CountTicksInProgress return count of ticks in progress

func (*TickManager) GetHandlers

func (t *TickManager) GetHandlers() map[uint64]*TickHandler

GetHandlers return all handlers

func (*TickManager) Remove

func (t *TickManager) Remove(id uint64)

Remove handler

func (*TickManager) Run

func (t *TickManager) Run()

Run all tickers

func (*TickManager) Stop

func (t *TickManager) Stop()

Stop all handlers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL