Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch[ARG, RET any] interface { // Execute the supplied tasks, and return the // and return the results.Multiple[RET] containing a channel for the results. // // The amount of tasks that can be executed at once is determined by the amount of workers. Run(workers, chanBufferSize Size) (results.Multiple[RET], ChannelControl) // Execute the supplied tasks, // and return the results.Multiple[RET] containing a channel for the results. // // The tasks will be executed at the given time. // // Tasks scheduled for the past will be executed immediately. RunAt(workers, chanBufferSize Size, t time.Time) (results.Multiple[RET], ChannelControl) // Add a task to the batch. // // This task can be provided with its own arguments. Add(task func(ARG) RET, arg ARG) // Add many tasks to the batch. // // All tasks will get the arguments provided to AddMany. AddMany(task []func(ARG) RET, arg ARG) // Add Funcs to the batch. // // This is a shortcut for AddMany. AddFuncs(funcs ...funcs.Func[ARG, RET]) }
A batch of functions
This batch can be used to execute multiple tasks at once.
The tasks can be either scheduled, or executed immediately.
The results are returned in a separate interface, containing a channel to read/wait for the the results.
type ChannelControl ¶
type ChannelControl interface { // Cancel the execution of the batch. // // All tasks in the buffer will be canceled. // // Already running tasks will be run to completion. Cancel() // Check if the batch has been fully executed or canceled. Done() <-chan struct{} }
A channel control is used to control the execution of the batch. It can be used to cancel the execution of the batch.
It can also be used to check if the batch has been fully executed.
type Size ¶
type Size uint32
The size type used inside the Batch interface.
This is a uint to make sure the size is always positive, as it might be used in channels and slices.
var MaxSafeBuffer Size = 16384
Maximum buffer size for the pool of executing funcs.
This is to prevent the pool from using too much memory.
Feel free to edit this variable.
var MaxSafeWorkers Size = getMaxWorkers(512) // 512 * logical cpu's
Maximum amount of workers for the pool of executing funcs.
This is to prevent running too many goroutines at once.
Feel free to edit this variable.