Documentation ¶
Index ¶
Constants ¶
View Source
const LoopTimeout = time.Second * 20
View Source
const SleepTime = time.Microsecond * 5
Variables ¶
View Source
var DefaultWorkerCount = runtime.NumCPU()
DefaultWorkerCount default workers count, depend on runtime cpu value
Functions ¶
This section is empty.
Types ¶
type ExecutionFn ¶
type Result ¶
type Result struct { Value interface{} Err error Descriptor TaskDescriptor }
type Task ¶
type Task struct { Args interface{} ExecFn ExecutionFn Descriptor TaskDescriptor }
type TaskDescriptor ¶
type TaskDescriptor struct { Metadata TaskMetadata TaskType TaskType ID TaskID }
type TaskMetadata ¶
type TaskMetadata map[string]interface{}
type WorkerPool ¶
type WorkerPool struct { Tasks chan Task // input tasks to work parallel following order Results chan Result // output result channel, results will be in order as per input task order WorkerPoolName string WorkerStopChannel []chan bool // worker stop channel WorkerInputReadyChannel []chan bool // worker input ready channel WorkerOutputReadyChannel []chan bool // worker output ready channel LoopTimeOut time.Duration // read loop timeout limit, default 2 seconds WorkersCount int TasksCount int }
func New ¶
func New(workerCount, tasksCount int, workerPoolName string) WorkerPool
func NewWithLoopTimeOut ¶
func NewWithLoopTimeOut(workerCount, tasksCount int, workerPoolName string, loopTimeOut time.Duration) WorkerPool
func (WorkerPool) GenerateFrom ¶
func (wp WorkerPool) GenerateFrom(bulkTasks []Task)
func (WorkerPool) Run ¶
func (wp WorkerPool) Run(ctx context.Context)
func (WorkerPool) StopWorkers ¶
func (wp WorkerPool) StopWorkers()
Click to show internal directories.
Click to hide internal directories.