workerpool

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package workerpool provides a worker pool for concurrent mutation testing execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// Start executes the task on worker. It stops the task when ctx is done.
	Start(ctx context.Context, worker *Worker)
}

Executor is the unit of work that executes a task.

type Pool

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

Pool manages and limits the number of concurrent Worker.

func Initialize

func Initialize(name string) *Pool

Initialize creates a new Pool with a name and the number of parallel workers it will use.

func (*Pool) ActiveWorkers

func (p *Pool) ActiveWorkers() int

ActiveWorkers gives the number of active workers on the Pool.

func (*Pool) AppendExecutor

func (p *Pool) AppendExecutor(ctx context.Context, executor Executor) bool

AppendExecutor adds a new Executor to the queue of Executor to be processed. It waits for a free place in the queue and returns false without adding the Executor when ctx is done first.

func (*Pool) Start

func (p *Pool) Start(ctx context.Context)

Start the Pool. The workers pass ctx to each executor.

func (*Pool) Stop

func (p *Pool) Stop()

Stop the Pool and wait for all the pending Worker to complete. Call Stop once, after the last AppendExecutor.

type Worker

type Worker struct {
	Name string
	ID   int
	// contains filtered or unexported fields
}

Worker takes an executor and starts the actual executor.

func NewWorker

func NewWorker(id int, name string) *Worker

NewWorker instantiates a new worker with an ID and name.

func (*Worker) Start

func (w *Worker) Start(ctx context.Context, executorQueue <-chan Executor)

Start gets an executor queue and starts working on it. It passes ctx to each executor. The worker exits when the queue is closed and drained.

Jump to

Keyboard shortcuts

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