threading

package
v3.2.7 Latest Latest
Warning

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

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

Documentation

Overview

threading package provides support for simple concurrency and threading

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	Name    string
	Process func() error
}

type ThreadPool

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

func NewThreadPool

func NewThreadPool(numberThreads int, loggingFrequency int, output bool, outputProgress bool) (*ThreadPool, error)

func NewThreadPoolWithJobQueue

func NewThreadPoolWithJobQueue(numberThreads, jobQueueSize int, loggingFrequency int, output bool, outputProgress bool) (*ThreadPool, error)

func (*ThreadPool) AddJob

func (t *ThreadPool) AddJob(job Job)

AddJob adds a job to the thread pool. It increases the wait group counter and sends the job to the jobs channel.

func (*ThreadPool) PendingJobs

func (t *ThreadPool) PendingJobs() int

PendingJobs returns the number of jobs that are pending.

func (*ThreadPool) ProcessAndWait

func (t *ThreadPool) ProcessAndWait() error

ProcessAndWait blocks until all jobs have finished. If no jobs were added, it returns an error.

Jump to

Keyboard shortcuts

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