threads

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine manages a pool of workers to execute tasks concurrently.

func NewEngine

func NewEngine(maxWorkers int) *Engine

NewEngine initializes a new Engine with a logger and an optimal number of workers.

func (*Engine) AddTask

func (e *Engine) AddTask(task Task)

AddTask adds a new task to the task channel, scaling workers if necessary.

func (*Engine) Start

func (e *Engine) Start()

Start launches the initial set of worker goroutines.

func (*Engine) Stop

func (e *Engine) Stop()

Stop gracefully shuts down the engine by closing the task channel and waiting for all workers to finish.

type Task

type Task func()

Task represents a unit of work to be executed by the engine.

Jump to

Keyboard shortcuts

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