Documentation
¶
Index ¶
- func GoSafe(fn func())
- func GoSafe0[Arg0 any](fn func(arg0 Arg0), arg0 Arg0)
- func GoSafe1[Arg0 any, Arg1 any](fn func(arg0 Arg0, arg1 Arg1), arg0 Arg0, arg1 Arg1)
- func GoSafeCtx(ctx context.Context, fn func())
- func RoutineId() uint64
- func RunSafe(fn func())
- func RunSafe0[Arg0 any](fn func(arg0 Arg0), arg0 Arg0)
- func RunSafe1[Arg0 any, Arg1 any](fn func(arg0 Arg0, arg1 Arg1), arg0 Arg0, arg1 Arg1)
- func RunSafeCtx(ctx context.Context, fn func())
- type Broadcast
- type PerpetualMotion
- type Pool
- type PoolWithFunc
- type RoutineGroup
- type RoutineGroup0
- type RoutineGroup1
- func (g *RoutineGroup1[Arg0, Arg1]) Run(fn func())
- func (g *RoutineGroup1[Arg0, Arg1]) Run1(fn func(arg0 Arg0, arg1 Arg1), arg0 Arg0, arg1 Arg1)
- func (g *RoutineGroup1[Arg0, Arg1]) RunSafe(fn func())
- func (g *RoutineGroup1[Arg0, Arg1]) RunSafe1(fn func(arg0 Arg0, arg1 Arg1), arg0 Arg0, arg1 Arg1)
- func (g *RoutineGroup1[Arg0, Arg1]) Wait()
- type Watch
- type WorkerGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoSafe ¶
func GoSafe(fn func())
GoSafe runs the given fn using another goroutine, recovers if fn panics.
func GoSafeCtx ¶ added in v0.1.0
GoSafeCtx runs the given fn using another goroutine, recovers if fn panics with ctx.
func RunSafeCtx ¶ added in v0.1.0
RunSafeCtx runs the given fn, recovers if fn panics with ctx.
Types ¶
type Broadcast ¶
type Broadcast[T any] struct { // contains filtered or unexported fields }
A Broadcast is used to run given number of workers to process jobs.
func NewBroadcast ¶
NewBroadcast returns a Broadcast with given job and workers.
type PerpetualMotion ¶
type PerpetualMotion struct { Debug bool // contains filtered or unexported fields }
A PerpetualMotion is used to run given number of workers to process jobs.
func NewPerpetualMotion ¶
func NewPerpetualMotion(job func(ctx context.Context) (time.Duration, error), workers int) PerpetualMotion
NewPerpetualMotion returns a NewPerpetualMotion with given job and workers.
func (PerpetualMotion) Stop ¶
func (m PerpetualMotion) Stop() error
type PoolWithFunc ¶
type PoolWithFunc struct {
// contains filtered or unexported fields
}
func NewPoolWithFunc ¶
func NewPoolWithFunc(size int, pf func(context.Context, interface{})) (pwf *PoolWithFunc, err error)
func (*PoolWithFunc) Close ¶
func (p *PoolWithFunc) Close()
func (*PoolWithFunc) Submit ¶
func (p *PoolWithFunc) Submit(i interface{}) error
type RoutineGroup ¶
type RoutineGroup struct {
// contains filtered or unexported fields
}
A RoutineGroup is used to group goroutines together and all wait all goroutines to be done.
func (*RoutineGroup) Run ¶
func (g *RoutineGroup) Run(fn func())
Run runs the given fn in RoutineGroup. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup) RunSafe ¶
func (g *RoutineGroup) RunSafe(fn func())
RunSafe runs the given fn in RoutineGroup, and avoid panics. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup) Wait ¶
func (g *RoutineGroup) Wait()
Wait waits all running functions to be done.
type RoutineGroup0 ¶ added in v0.1.0
type RoutineGroup0[Arg0 any] struct { // contains filtered or unexported fields }
A RoutineGroup0 is used to group goroutines together and all wait all goroutines to be done.
func NewRoutineGroup0 ¶ added in v0.1.0
func NewRoutineGroup0[Arg0 any]() *RoutineGroup0[Arg0]
NewRoutineGroup0 returns a RoutineGroup.
func (*RoutineGroup0[Arg0]) Run ¶ added in v0.1.0
func (g *RoutineGroup0[Arg0]) Run(fn func())
Run runs the given fn in RoutineGroup. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup0[Arg0]) Run0 ¶ added in v0.1.0
func (g *RoutineGroup0[Arg0]) Run0(fn func(arg0 Arg0), arg0 Arg0)
Run0 runs the given fn in RoutineGroup. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup0[Arg0]) RunSafe ¶ added in v0.1.0
func (g *RoutineGroup0[Arg0]) RunSafe(fn func())
RunSafe runs the given fn in RoutineGroup, and avoid panics. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup0[Arg0]) RunSafe0 ¶ added in v0.1.0
func (g *RoutineGroup0[Arg0]) RunSafe0(fn func(arg0 Arg0), arg0 Arg0)
RunSafe0 runs the given fn in RoutineGroup, and avoid panics. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup0[Arg0]) Wait ¶ added in v0.1.0
func (g *RoutineGroup0[Arg0]) Wait()
Wait waits all running functions to be done.
type RoutineGroup1 ¶ added in v0.1.0
A RoutineGroup1 is used to group goroutines together and all wait all goroutines to be done.
func NewRoutineGroup1 ¶ added in v0.1.0
func NewRoutineGroup1[Arg0 any, Arg1 any]() *RoutineGroup1[Arg0, Arg1]
NewRoutineGroup1 returns a RoutineGroup.
func (*RoutineGroup1[Arg0, Arg1]) Run ¶ added in v0.1.0
func (g *RoutineGroup1[Arg0, Arg1]) Run(fn func())
Run runs the given fn in RoutineGroup. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup1[Arg0, Arg1]) Run1 ¶ added in v0.1.0
func (g *RoutineGroup1[Arg0, Arg1]) Run1(fn func(arg0 Arg0, arg1 Arg1), arg0 Arg0, arg1 Arg1)
Run1 runs the given fn in RoutineGroup. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup1[Arg0, Arg1]) RunSafe ¶ added in v0.1.0
func (g *RoutineGroup1[Arg0, Arg1]) RunSafe(fn func())
RunSafe runs the given fn in RoutineGroup, and avoid panics. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup1[Arg0, Arg1]) RunSafe1 ¶ added in v0.1.0
func (g *RoutineGroup1[Arg0, Arg1]) RunSafe1(fn func(arg0 Arg0, arg1 Arg1), arg0 Arg0, arg1 Arg1)
RunSafe1 runs the given fn in RoutineGroup, and avoid panics. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup1[Arg0, Arg1]) Wait ¶ added in v0.1.0
func (g *RoutineGroup1[Arg0, Arg1]) Wait()
Wait waits all running functions to be done.
type Watch ¶ added in v0.0.16
type Watch[T any] struct { // contains filtered or unexported fields }
A Watch is used to run given number of workers to process jobs.
type WorkerGroup ¶
type WorkerGroup struct {
// contains filtered or unexported fields
}
A WorkerGroup is used to run given number of workers to process jobs.
func NewWorkerGroup ¶
func NewWorkerGroup(job func(), workers int) WorkerGroup
NewWorkerGroup returns a WorkerGroup with given job and workers.