threadpool

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 6 Imported by: 0

README

go-threadpool

Implements a thread pool in Golang (1.18+)

Installation

go get github.com/AlexandreChamard/go-threadpool

Examples

See the test code.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State int
const (
	State_ERROR         State = 0
	State_RUNNING       State = 1
	State_WAIT_FOR_STOP State = 2
	State_STOPPED       State = 3
)

type ThreadPool

type ThreadPool interface {
	Submit(f Functor)
	// Priority: higher value == higher priority
	SubmitPriority(f Functor, priority int)
	// /!\ Does not block, after stopped, use Wait() to wait for all running process to end
	// Wait for all task to be executed
	Stop()
	// /!\ Does not block, after stopped, use Wait() to wait for all running process to end
	// Does not wait for all task to be executed
	ForceStop()
	// Wait for all processes to complete
	Wait()
}

func NewThreadPool

func NewThreadPool(config ThreadPoolConfig) ThreadPool

n: maximum number of parellel executions

type ThreadPoolConfig

type ThreadPoolConfig struct {
	PoolSize  int
	EnableLog bool
}

Jump to

Keyboard shortcuts

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