frostfs-node/pkg/util/worker_pool.go
Leonard Lyubich 07130855aa [#674] util: Rename SyncWorkerPool with PseudoWorkerPool
`SyncWorkerPool` name is more appropriate for worker pool of size 1.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-10-14 10:20:39 +03:00

24 lines
622 B
Go

package util
// WorkerPool represents the tool for control
// the execution of go-routine pool.
type WorkerPool interface {
// Submit queues a function for execution
// in a separate routine.
//
// Implementation must return any error encountered
// that prevented the function from being queued.
Submit(func()) error
}
// PseudoWorkerPool represents pseudo worker pool which executes submitted job immediately in the caller's routine..
type PseudoWorkerPool struct{}
// Submit executes passed function immediately.
//
// Always returns nil.
func (PseudoWorkerPool) Submit(fn func()) error {
fn()
return nil
}