Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultWorkers = Workers(runtime.GOMAXPROCS(0))
DefaultWorkers is a default instance of Workers with the size of GOMAXPROCS.
Functions ¶
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(), bool)
}
Job interface defines a method to get the next job function. The returned bool indicates whether there might be more jobs. - (f, true): got a job, and there may be more. - (f, false): got a job, but this is the last one. - (nil, false): no more jobs.
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.