routine

package module
v0.0.0-...-38d933c Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(numWorkers int, maxJobQueueLen int, maxJobTimeout time.Duration)

func PutTask

func PutTask(f Function)

func QueueLen

func QueueLen() int

func Stop

func Stop()

Types

type BaseTask

type BaseTask struct {
	Name string
	F    Function
}

func (*BaseTask) Execute

func (t *BaseTask) Execute()

func (*BaseTask) GetTaskName

func (t *BaseTask) GetTaskName() string

type Function

type Function func()

func (Function) Execute

func (f Function) Execute()

func (Function) GetTaskName

func (f Function) GetTaskName() string

type Pool

type Pool struct {
	Name     string
	JobQueue chan Task
	// contains filtered or unexported fields
}

func InitPoolWithName

func InitPoolWithName(name string, numWorkers int, maxJobQueueLen int, maxJobTimeout time.Duration) *Pool

func NewPool

func NewPool(numWorkers int, maxJobQueueLen int, maxJobTimeout time.Duration) *Pool

func (*Pool) Put

func (p *Pool) Put(f Function) bool

func (*Pool) PutWait

func (p *Pool) PutWait(f Function)

func (*Pool) PutWithTaskName

func (p *Pool) PutWithTaskName(task *BaseTask) bool

func (*Pool) QueueLen

func (p *Pool) QueueLen() int

func (*Pool) Start

func (p *Pool) Start()

func (*Pool) Stop

func (p *Pool) Stop()

func (*Pool) StopWait

func (p *Pool) StopWait()

type Task

type Task interface {
	GetTaskName() string
	Execute()
}

Jump to

Keyboard shortcuts

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