Documentation
¶
Index ¶
- Variables
- type Pool
- func (p *Pool[T]) ActiveTasks() int
- func (p *Pool[T]) Cancel(err ...error)
- func (p *Pool[T]) CancelOnError() *Pool[T]
- func (p *Pool[T]) Cause() error
- func (p *Pool[T]) ClearMetrics()
- func (p *Pool[T]) Context(ctx context.Context) *Pool[T]
- func (p *Pool[T]) FailedTasks() int
- func (p *Pool[T]) GetContext() context.Context
- func (p *Pool[T]) Go(fn func() Result[T])
- func (p *Pool[T]) Limit(workers int) *Pool[T]
- func (p *Pool[T]) Reset() error
- func (p *Pool[T]) TotalTasks() int
- func (p *Pool[T]) Wait() SeqResult[T]
Constants ¶
This section is empty.
Variables ¶
var ErrAllTasksDone = errors.New("all tasks completed")
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
Pool[T any] is a goroutine pool that allows parallel task execution.
func (*Pool[T]) ActiveTasks ¶
ActiveTasks returns the current number of tasks that are still running.
func (*Pool[T]) CancelOnError ¶
CancelOnError enables cancellation of remaining tasks on failure.
func (*Pool[T]) Cause ¶
Cause returns the reason for the cancellation of the pool's context. It retrieves the underlying cause of the context's termination if the context has been canceled. If the pool's context is still active, it returns nil.
func (*Pool[T]) ClearMetrics ¶
func (p *Pool[T]) ClearMetrics()
ClearMetrics resets both total tasks and failed tasks counters to zero.
func (*Pool[T]) Context ¶
Context replaces the pool’s context with the provided context. If ctx is nil, context.Background() is used by default.
func (*Pool[T]) FailedTasks ¶
FailedTasks returns the number of tasks that have completed with an error.
func (*Pool[T]) GetContext ¶
GetContext returns the current context associated with the pool.
func (*Pool[T]) Go ¶
func (p *Pool[T]) Go(fn func() Result[T])
Go launches an asynchronous task fn() in its own goroutine.
func (*Pool[T]) Reset ¶
Reset restores the pool to its initial state: cancels all tasks, clears results and metrics, and creates a new context.
func (*Pool[T]) TotalTasks ¶
TotalTasks returns the total number of tasks that have been submitted.