luci: go.chromium.org/luci/server/tq/internal/workset Index | Files

package workset

import "go.chromium.org/luci/server/tq/internal/workset"

Package workset contains a synchronized work queue implementation used by inproc sweeper.

Index

Package Files

workset.go

type Item Uses

type Item interface{}

Item is one item that when processed may result in more items.

type WorkSet Uses

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

WorkSet represents an unordered collection of some work items.

Each item, when processed, may produce more follow up work items.

func New Uses

func New(work []Item, r *rand.Rand) *WorkSet

New creates a new WorkSet and seeds it with the initial set of work items.

If `r` is non-nil the workset will use it to randomize which items are picked up by Pop. Otherwise it will use the global math/rand source.

func (*WorkSet) Pop Uses

func (ws *WorkSet) Pop(ctx context.Context) (item Item, done func([]Item))

Pop blocks until there's some work item available and then pops it.

Once it happens, it also increments "somebody is working" counter. The worker should eventually call `done(<more work items>)` or `done(nil)` to indicate that it has finished processing the item.

If there's no available work items and no one is working (and thus no new items may ever appear), returns nil. Returns nil as well if the context is canceled.

Package workset imports 3 packages (graph) and is imported by 1 packages. Updated 2020-09-30. Refresh now. Tools for package owners.