par

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Copyright 2023 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Work

type Work[T comparable] struct {
	// contains filtered or unexported fields
}

Work manages a set of work items to be executed in parallel, at most once each. The items in the set must all be valid map keys.

func (*Work[T]) Add

func (w *Work[T]) Add(item T)

Add adds item to the work set, if it hasn't already been added.

func (*Work[T]) Do

func (w *Work[T]) Do(n int, f func(item T))

Do runs f in parallel on items from the work set, with at most n invocations of f running at a time. It returns when everything added to the work set has been processed. At least one item should have been added to the work set before calling Do (or else Do returns immediately), but it is allowed for f(item) to add new items to the set. Do should only be used once on a given Work.

Jump to

Keyboard shortcuts

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