frostfs-node/pkg/util/worker_pool.go
Leonard Lyubich d52bdb27c5 [#33] util: Define worker pool interface
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-10-02 11:25:35 +03:00

24 lines
555 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
}
// SyncWorkerPool represents synchronous worker pool.
type SyncWorkerPool struct{}
// Submit executes passed function immediately.
//
// Always returns nil.
func (SyncWorkerPool) Submit(fn func()) error {
fn()
return nil
}