Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDispatcherClosed = errors.New("dispatcher has been closed")
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher[T any] struct { // contains filtered or unexported fields }
func NewDispatcher ¶
func NewDispatcher[T any](ctx context.Context, dispatchFunc func([]T), batchSize int) *Dispatcher[T]
NewDispatcher creates a generic dispatcher that can receive values from multiple goroutines in a thread-safe manner and process each element serially using the dispatchFunc
func (*Dispatcher[T]) CloseAndWait ¶
func (d *Dispatcher[T]) CloseAndWait()
CloseAndWait closes the dispatcher and waits for all pending elements to be processed
func (*Dispatcher[T]) Len ¶
func (d *Dispatcher[T]) Len() uint64
Len returns the number of elements in the dispatcher's buffer
func (*Dispatcher[T]) ReadCount ¶
func (d *Dispatcher[T]) ReadCount() uint64
ReadCount returns the number of elements read from the dispatcher's buffer
func (*Dispatcher[T]) Write ¶
func (d *Dispatcher[T]) Write(values ...T) error
Write writes values to the dispatcher
func (*Dispatcher[T]) WriteCount ¶
func (d *Dispatcher[T]) WriteCount() uint64
WriteCount returns the number of elements written to the dispatcher
Click to show internal directories.
Click to hide internal directories.