Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultWorkers = NewWorkers(int64(runtime.GOMAXPROCS(0)))
DefaultWorkers is a default instance of Workers with the size of GOMAXPROCS.
Functions ¶
This section is empty.
Types ¶
type Integer ¶
type Integer interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
Integer interface defines a set of integer types.
type Job ¶
type Job interface {
Next() func()
}
Job interface defines a method to get the next job function.
func MapJob ¶
func MapJob[M ~map[K]V, K comparable, V any](m M, f func(K, V)) Job
MapJob creates a Job that iterates over a map and applies a function to each key-value pair.
type JobList ¶
type JobList[T any] struct { // contains filtered or unexported fields }
JobList is a struct that holds a list of jobs, a worker pool, a function to execute jobs, a channel for signaling, and a boolean indicating if the job list is closed.
func NewJobList ¶
NewJobList creates a new JobList with the given worker pool and job function.
func (*JobList[T]) PushBack ¶
PushBack adds a job to the end of the job list and signals the worker pool.
type Workers ¶
type Workers struct {
// contains filtered or unexported fields
}
Workers struct holds the size and semaphore for managing concurrent jobs.
func NewWorkers ¶
NewWorkers creates a new Workers instance with a given size.
func (*Workers) Listen ¶
Listen listens for jobs from a channel and runs them concurrently. It stops listening when the context is done or the channel is closed.