parallel

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MaxWorkers = math.MaxInt / 2

MaxWorkers is the maximum number of workers allowed in a pool.

Variables

View Source
var ErrTooManyWorkers = fmt.Errorf("worker count exceeds maximum")

ErrTooManyWorkers is returned when the worker count exceeds the maximum allowed.

Functions

This section is empty.

Types

type ParallelTraverser

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

ParallelTraverser performs parallel graph traversals

func NewParallelTraverser

func NewParallelTraverser(graph *storage.GraphStorage, numWorkers int) (*ParallelTraverser, error)

NewParallelTraverser creates a new parallel traverser

func (*ParallelTraverser) Close

func (pt *ParallelTraverser) Close()

Close closes the worker pool

func (*ParallelTraverser) ParallelShortestPath

func (pt *ParallelTraverser) ParallelShortestPath(startNode, endNode uint64, maxDepth int) ([]uint64, error)

ParallelShortestPath finds shortest paths using parallel BFS

func (*ParallelTraverser) TraverseBFS

func (pt *ParallelTraverser) TraverseBFS(startNodes []uint64, maxDepth int) []uint64

TraverseBFS performs parallel breadth-first traversal

func (*ParallelTraverser) TraverseDFS

func (pt *ParallelTraverser) TraverseDFS(startNode uint64, maxDepth int) []uint64

TraverseDFS performs parallel depth-first traversal Note: DFS is inherently less parallelizable than BFS

type WorkerPool

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

WorkerPool manages a pool of worker goroutines

func NewWorkerPool

func NewWorkerPool(workers int) (*WorkerPool, error)

NewWorkerPool creates a new worker pool with specified number of workers. Returns an error if the worker count exceeds MaxWorkers.

func (*WorkerPool) Close

func (wp *WorkerPool) Close()

Close shuts down the worker pool

func (*WorkerPool) Submit

func (wp *WorkerPool) Submit(task func()) bool

Submit adds a task to the worker pool Returns false if the pool is closed, true if task was submitted

func (*WorkerPool) Wait

func (wp *WorkerPool) Wait()

Wait waits for all submitted tasks to complete

Jump to

Keyboard shortcuts

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