workerpool

package
v0.0.0-...-15a9106 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0, BSD-2-Clause Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	// PendingChildrenCounter contains the number of children that are currently pending.
	PendingChildrenCounter *syncutils.Counter
	// contains filtered or unexported fields
}

Group is a group of WorkerPools that can be managed as a whole.

func NewGroup

func NewGroup(name string) *Group

NewGroup creates a new Group.

func (*Group) CreateGroup

func (g *Group) CreateGroup(name string) *Group

CreateGroup creates a new Group with the given name and returns it.

func (*Group) CreatePool

func (g *Group) CreatePool(name string, optWorkerCount ...int) *WorkerPool

CreatePool creates a new WorkerPool with the given name and returns it.

func (*Group) Group

func (g *Group) Group(name string) (pool *Group, exists bool)

Group returns the Group with the given name.

func (*Group) IsShutdown

func (g *Group) IsShutdown() bool

IsShutdown returns true if the group was shutdown.

func (*Group) Name

func (g *Group) Name() (name string)

Name returns the name of the Group.

func (*Group) Pool

func (g *Group) Pool(name string) (pool *WorkerPool, exists bool)

Pool returns the WorkerPool with the given name.

func (*Group) Pools

func (g *Group) Pools() map[string]*WorkerPool

Pools returns all WorkerPools of the Group.

func (*Group) Root

func (g *Group) Root() *Group

Root returns the root Group of the Group.

func (*Group) Shutdown

func (g *Group) Shutdown()

Shutdown shuts down all child elements of the Group.

func (*Group) String

func (g *Group) String() string

String returns a human-readable string representation of the Group.

func (*Group) WaitChildren

func (g *Group) WaitChildren()

WaitChildren waits until all children of the Group are idle.

func (*Group) WaitParents

func (g *Group) WaitParents()

WaitParents waits until all parents of the Group are idle.

type Task

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

Task is a task that is executed by a WorkerPool.

type WorkerPool

type WorkerPool struct {
	// Name is the name of the WorkerPool.
	Name string

	// PendingTasksCounter is the number of tasks that are currently pending.
	PendingTasksCounter *syncutils.Counter

	// Queue is the queue of tasks that are waiting to be executed.
	Queue *syncutils.Stack[*Task]

	// ShutdownComplete is a WaitGroup that is used to wait for the WorkerPool to shutdown.
	ShutdownComplete sync.WaitGroup
	// contains filtered or unexported fields
}

WorkerPool is a pool of workers that can execute tasks.

func New

func New(name string, optsWorkerCount ...int) *WorkerPool

New creates a new WorkerPool with the given name and returns it.

func (*WorkerPool) IsRunning

func (w *WorkerPool) IsRunning() bool

IsRunning returns true if the WorkerPool is running.

func (*WorkerPool) Shutdown

func (w *WorkerPool) Shutdown(cancelPendingTasks ...bool) *WorkerPool

Shutdown shuts down the WorkerPool.

func (*WorkerPool) Start

func (w *WorkerPool) Start() *WorkerPool

Start starts the WorkerPool.

func (*WorkerPool) Submit

func (w *WorkerPool) Submit(workerFunc func(), optStackTrace ...string)

Submit submits a new task to the WorkerPool.

func (*WorkerPool) WorkerCount

func (w *WorkerPool) WorkerCount() int

WorkerCount returns the number of workers that are used to execute tasks.

Jump to

Keyboard shortcuts

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