Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrTimeout = errors.New("add to job queue timeout")
)
Functions ¶
This section is empty.
Types ¶
type PanicFunc ¶
type PanicFunc func(recovered interface{}, funcName string)
PanicFunc is a function will process panic which throw in worker function
type TimeoutCond ¶
TimeoutCond is a sync.Cond improve for support wait timeout.
func NewTimeoutCond ¶
func NewTimeoutCond(l sync.Locker) *TimeoutCond
NewTimeoutCond return a new TimeoutCond
func (*TimeoutCond) HasWaiters ¶
func (cond *TimeoutCond) HasWaiters() bool
HasWaiters queries whether any goroutine are waiting on this condition
func (*TimeoutCond) Interrupt ¶
func (cond *TimeoutCond) Interrupt()
Interrupt goroutine wait on this TimeoutCond
func (*TimeoutCond) Signal ¶
func (cond *TimeoutCond) Signal()
Signal wakes one goroutine waiting on c, if there is any.
type WorkerPool ¶
type WorkerPool interface { // Execute add worker function to queue to wait for executing by worker goroutine Execute(f JobFunc) // Execute summit worker function to queue with a timeout timer, // if add queue success it will wait for executing by worker goroutine Submit(f JobFunc, timeout time.Duration) error // Stop cancel all goroutines started by this pool and wait Shutdown(ctx context.Context) // Stats return the statistics of worker pool Stats() WpStats // Option return the configuration of worker pool Option() WpOption }
func NewWorkerPool ¶
func NewWorkerPool(opt ...WpOption) WorkerPool
NewWorkerPool creates a instance of WorkerPool with given option default parameters:
queueSize: 100 initWorkerNum: 2 maxWorkerNum: 50
Click to show internal directories.
Click to hide internal directories.