forked from TrueCloudLab/frostfs-node
[#33] util: Define worker pool interface
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
d3b5ff9526
commit
d52bdb27c5
1 changed files with 24 additions and 0 deletions
24
pkg/util/worker_pool.go
Normal file
24
pkg/util/worker_pool.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
}
|
Loading…
Reference in a new issue