62
// from your task.Run method. When a task is deferred, it will be added to the tail of a
63
// deferredTaskQ which in turn will be processed after the current runQ is drained
64
>
func NewFixedSizePoolExecutor(size int, maxDeferred int, metricsHandler metrics.Handler, operation string) Executor {
executor.go
65
>
stopC := make(chan struct{})
66
>
return &fixedPoolExecutor{
67
>
size: size,
68
>
maxDeferred: maxDeferred,
69
>
runQ: newRunQueue(size, stopC),
70
>
metricsHandler: metricsHandler.WithTags(metrics.OperationTag(operation)),
71
>
stopC: stopC,
72
>
}
73
>
}
74
75
// Start starts the executor
77
>
if !atomic.CompareAndSwapInt32(&e.status, common.DaemonStatusInitialized, common.DaemonStatusStarted) {
78
return
79
}
81
>
e.stopWG.Add(1)
82
>
go e.worker()
83
>
}
84
}
85
86
// Stop stops the executor
88
>
if !atomic.CompareAndSwapInt32(&e.status, common.DaemonStatusStarted, common.DaemonStatusStopped) {
89
return
90
}
92
>
e.stopWG.Wait()
93
}
94