worker

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Active

func Active() *active

func FnvBytes

func FnvBytes(bytes []byte) int64

func FnvInt64

func FnvInt64(v int64) int64

func FnvStr

func FnvStr(key string) int64

func Global

func Global() *global

func Go

func Go(fn util.FnAnySlc, params ...any)

func InitActive

func InitActive(opts ...ActiveOption)

func InitGlobal

func InitGlobal()

func InitParallel

func InitParallel()

func InitShare

func InitShare()

func MemHash

func MemHash(data []byte) int64

func MemHashString

func MemHashString(str string) int64

func NewGlobal

func NewGlobal() *global

func P

func P[DT any](data []DT, fn func(DT))

func PFn

func PFn(fns []util.FnAnySlc, params ...any)

func PParams

func PParams[DT any](data []DT, fn func(DT, []any), params ...any)
func PParamsToFnLink[DT any](data []DT, fn func(DT, []any, *ds.FnLink), params ...any)
func PParamsToToLink[InT, OutT any](data []InT, fn func(InT, []any, *ds.Link[OutT]),
	pcr func(*ds.Link[OutT]), params ...any)

func PTo

func PTo[DT1, DT2 any](data []DT1, fn func(DT1) DT2, complete func([]DT2))
func PToFnLink[DT any](data []DT, fn func(DT, *ds.FnLink))
func PToLink[InT, OutT any](data []InT, fn func(InT, *ds.Link[OutT]),
	pcr func(*ds.Link[OutT]))

func PushPJob

func PushPJob(job IJob)

func RecycleJob

func RecycleJob(job *Job)

func Self

func Self(fn util.FnAnySlc, params ...any)

func Share

func Share() *fnShare

Types

type ActiveOption

type ActiveOption func(o *activeOption)

func ActiveCap

func ActiveCap(cap int) ActiveOption

ActiveCap 设置活跃初始容量

func ActiveTickSecs

func ActiveTickSecs(seconds int64) ActiveOption

ActiveTickSecs 设置活跃的检测间隔时间

type FnJob

type FnJob func(*Job)

type FnJobData

type FnJobData struct {
	Fn     util.FnAnySlc
	Params []any
}

type FnWorker

type FnWorker struct {
	*Worker[FnJobData]
}

func NewFnWorker

func NewFnWorker() *FnWorker

func (*FnWorker) Push

func (w *FnWorker) Push(fn util.FnAnySlc, params ...any)

type IJob

type IJob interface {
	Do()
}

type Job

type Job struct {
	Name JobName
	Data []any
}

func SpawnJob

func SpawnJob() *Job

type JobName

type JobName = string

type JobWorker

type JobWorker struct {
	*Worker[*Job]
	// contains filtered or unexported fields
}

func NewJobWorker

func NewJobWorker(fn FnJob) *JobWorker

func (*JobWorker) Push

func (w *JobWorker) Push(name JobName, data ...any)

type Worker

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

func NewWorker

func NewWorker[T any](fn func(T)) *Worker[T]

func (*Worker[T]) Dispose

func (w *Worker[T]) Dispose()

func (*Worker[T]) Push

func (w *Worker[T]) Push(item T)

func (*Worker[T]) Start

func (w *Worker[T]) Start()

Jump to

Keyboard shortcuts

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