Documentation ¶
Overview ¶
Package workset contains a synchronized work queue implementation used by inproc sweeper.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WorkSet ¶
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 ¶
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 ¶
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.