Documentation ¶
Index ¶
- Variables
- func Pipe[IN, OUT any](dp *Pools, in <-chan IN, do func(*Pools, IN) OUT) <-chan OUT
- func Run[T any](pool *Pools, in <-chan T, proc PoolProcess[T])
- func RunAll[T any](pool *Pools, in <-chan T, procs []PoolProcess[T])
- type AnyProcess
- type Dispatch
- type Merge
- type PoolProcess
- type Pools
- type Process
- type Split
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidDispatcher = errors.New("invalid dispatcher")
Functions ¶
func Pipe ¶
Pipe allows to Pipe a channel in and out in the depth pool. It will execute the task in the current pool and pass the next level pool to the child task.
func Run ¶
func Run[T any](pool *Pools, in <-chan T, proc PoolProcess[T])
Run executes a pool process on a channel and wait until the input channel is closed and the process is terminated.
func RunAll ¶
func RunAll[T any](pool *Pools, in <-chan T, procs []PoolProcess[T])
RunAll is a convenient function to run a list of Poolprocess, in order.
Types ¶
type AnyProcess ¶
type AnyProcess[T any] interface { Process[T] | PoolProcess[T] }
Link merge several Process to one.
type Dispatch ¶
type Dispatch[Parent, Child any] struct { // contains filtered or unexported fields }
Dispatch combines Split and Merge since there are linked. Basically, in a program flows we will do : `parent -(Split)-> [childs...] -(Merge)-> parent`.
type Merge ¶
type Merge[Parent, Child any] func(parent Parent, out <-chan Child) Parent
Merge defines a operation which allow a Parent to be updated from several childs. The updated parent is returned.
type PoolProcess ¶
PoolProcess defines a basic function which update a variable and return the updated variable, but with the capability to parralelize its execution in a Pool.
func AsPoolProcess ¶
func AsPoolProcess[T any](proc Process[T]) PoolProcess[T]
AsPoolProcess decorates a Process, in order to make it seen as a PoolProcess.
func AsPoolProcesses ¶
func AsPoolProcesses[T any](procs ...Process[T]) []PoolProcess[T]
AsPoolProcesses is an helper function to call AsPoolProcess on lists.
func Link ¶
func Link[T any](procs ...PoolProcess[T]) PoolProcess[T]
LinkP merge several PoolProcess to one.
func Wrap ¶
func Wrap[Parent, Child any](procs PoolProcess[Child], dispatch Dispatch[Parent, Child]) PoolProcess[Parent]
Wrap creates a PoolProcess parent from a child pool process and a dispatcher. Child PoolProcess will be called concurrently triggered by dispatcher Split function, then merged into through the dispatcher Merge function.
type Pools ¶
type Pools struct {
// contains filtered or unexported fields
}
Pools define a slice of in depth pools.
func NewPools ¶
NewPools builds a depth pools with the size in parameters. If there is no size, no pools will be created. Submit will not run in parallel.
func NewPoolsWithOptions ¶
NewPoolsWithOptions builds a depth pools with the size in parameters. If there is no size, no pools will be created. Submit will not run in parallel.
Moreover, a size of 0 means that the task pushed at this level will run in their parent routine (or alike).