spawner

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package spawner implements dynamic goroutine management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RestartMode

type RestartMode int

RestartMode is a mode for spawning threads.

const (
	// RestartNever is a mode where goroutines are not restarted once they finish.
	RestartNever RestartMode = iota
	// RestartAlways is a mode that ensures goroutines are automatically restarted to maintain the capacity.
	RestartAlways
)

type SpawnFunc

type SpawnFunc func(ctx context.Context)

SpawnFunc is a target function for concurrent execution.

type Spawner

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

Spawner is a goroutine manager.

func New

func New(f SpawnFunc, mode RestartMode) *Spawner

New returns a new Spawner.

func (*Spawner) Cap

func (s *Spawner) Cap(count int)

Cap sets the maximum number of concurrent goroutines.

func (*Spawner) Count

func (s *Spawner) Count() int64

Count returns the number of currently running goroutines.

func (*Spawner) Start

func (s *Spawner) Start()

Start starts the goroutine manager.

func (*Spawner) Stop

func (s *Spawner) Stop()

Stop stops the goroutine manager.

func (*Spawner) StopAllThreads

func (s *Spawner) StopAllThreads()

StopAllThreads stops all running goroutines.

Jump to

Keyboard shortcuts

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