task

package
v0.0.50-alpha.88 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Least strategy = iota + 1
)

Variables

View Source
var (
	ErrGlobalQueueFull     = errors.New("global Queue is full")
	ErrWaitingQueueFull    = errors.New("waiting Queue is full")
	ErrProcessingQueueFull = errors.New("processing Queue is full")
	ErrDataNotFound        = errors.New("data not found")
)

Functions

func LeastTask

func LeastTask[T any, K comparable](tm *QueueManager[T, K]) (K, bool)

LeastTask : return key witch has the least tasks

Types

type Options

type Options[T any, K comparable] func(*QueueManager[T, K])

func WithAfterProcessPushFunc

func WithAfterProcessPushFunc[T any, K comparable](fs ...func(key K, data T)) Options[T, K]

func WithStrategy

func WithStrategy[T any, K comparable](s strategy) Options[T, K]

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue will pop data from its waiting Queue. If it`s empty, it will pop data from global Queue(in QueueManager), and then push to process Queue.

type QueueManager

type QueueManager[T any, K comparable] struct {
	// contains filtered or unexported fields
}

func NewQueueManager

func NewQueueManager[T any, K comparable](
	maxGlobal, maxProcessing, maxWaiting int,
	equalFunc func(a, b T) bool,
	opts ...Options[T, K],
) *QueueManager[T, K]

func (*QueueManager[T, K]) Delete

func (tm *QueueManager[T, K]) Delete(key K, data T) error

Delete will delete a data in key queues. If delete a data in processing Queue, taskQueue will pop data from its waiting Queue. If it`s empty, it will pop data from global Queue, and then push to process Queue.

func (*QueueManager[T, K]) GetProcessingQueueLengths

func (tm *QueueManager[T, K]) GetProcessingQueueLengths() map[K]int

func (*QueueManager[T, K]) Insert

func (tm *QueueManager[T, K]) Insert(data T) error

func (*QueueManager[T, K]) InsertByKey

func (tm *QueueManager[T, K]) InsertByKey(key K, data T) error

Jump to

Keyboard shortcuts

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