Documentation
¶
Index ¶
- func Execute(wp *WorkerPool, task func())
- type Future
- func (f *Future[T]) CastOrDefault(result interface{}, err error) (T, error)
- func (f *Future[T]) Get() (T, error)
- func (f *Future[T]) HandleError(handleError func(error))
- func (f *Future[T]) IsDone() bool
- func (f *Future[T]) IsRunning() bool
- func (f *Future[T]) Map(next func(T) (T, error)) *Future[T]
- func (f *Future[T]) ThenAccept(next func(T, error))
- func (f *Future[T]) ThenApply(next func(T, error) (T, error)) *Future[T]
- func (f *Future[T]) ThenDo(next func())
- type IFuture
- func (f *IFuture) FlatMap(next func(interface{}) (interface{}, error)) interface{}
- func (f *IFuture) Get() (interface{}, error)
- func (f *IFuture) IsDone() bool
- func (f *IFuture) IsRunning() bool
- func (f *IFuture) IsRunningOrDone() bool
- func (f *IFuture) Map(next func(interface{}) (interface{}, error)) *IFuture
- func (f *IFuture) ThenAccept(next func(interface{}, error))
- func (f *IFuture) ThenApply(next func(interface{}, error) (interface{}, error)) *IFuture
- func (f *IFuture) ThenDo(next func())
- type Task
- type WorkerPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute(wp *WorkerPool, task func())
Execute adds a task to the task queue to be processed by the workers
Types ¶
type Future ¶
type Future[T any] struct { // contains filtered or unexported fields }
func Submit ¶
func Submit[T any](wp *WorkerPool, defaultValue T, task func()) *Future[T]
func SubmitWithError ¶
func SubmitWithError[T any](wp *WorkerPool, defaultValue T, task func() (T, error)) *Future[T]
SubmitWithError adds a task to the task queue to be processed by the workers and logs error if there was one
func (*Future[T]) CastOrDefault ¶
func (*Future[T]) HandleError ¶
func (*Future[T]) ThenAccept ¶
type IFuture ¶
type IFuture struct {
// contains filtered or unexported fields
}
func NewIFuture ¶
func NewIFuture[T any](payload func() (T, error), pool *WorkerPool) *IFuture
func (*IFuture) IsRunningOrDone ¶
func (*IFuture) ThenAccept ¶
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task represents a unit of work to be processed by the worker pool
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool is a struct that manages a pool of workers to process tasks
func NewWorkerPool ¶
func NewWorkerPool() *WorkerPool
NewWorkerPool initializes a new WorkerPool with the optimal number of workers
func NewWorkerPoolWithMax ¶
func NewWorkerPoolWithMax(maxWorkers int) *WorkerPool
NewWorkerPool initializes a new WorkerPool with the optimal number of workers
func (*WorkerPool) Stop ¶
func (wp *WorkerPool) Stop()
Stop gracefully shuts down the worker pool by closing the task queue and waiting for workers to finish
func (*WorkerPool) Wait ¶
func (wp *WorkerPool) Wait()
Click to show internal directories.
Click to hide internal directories.