Documentation ¶
Overview ¶
Package combiner implements combining-queue for race-free batching of operations.
Index ¶
- type Batcher
- type Parking
- type Spinningdeprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batcher ¶
type Batcher interface { // Start is called on a start of a new batch. Start() // Do is called for each batch element. Do(arg interface{}) // Finish is called after completing a batch. Finish() }
Batcher is the operation combining implementation.
Batcher must not panic.
type Parking ¶
type Parking struct {
// contains filtered or unexported fields
}
Parking is a bounded non-spinning combiner queue.
This implementation is useful when the batcher work is large ore there are many goroutines concurrently calling Do. A good example would be a appending to a file.
func NewParking ¶
NewParking creates a Parking combiner queue
type Spinning
deprecated
type Spinning struct {
// contains filtered or unexported fields
}
Spinning is a combiner queue with spinning waiters.
This implementation is useful when the batcher work is small and there are few goroutines concurrently calling Do. A good example would be a shared data-structure.
If very high performance is required benchmark replacing Batcher and argument with concrete implementation.
Deprecated: This may cause problems with OS or runtime scheduler. Use Parking implementation instead.
func NewSpinning ¶
NewSpinning creates a spinning combiner with the given limit