Pool 2.0 - Go consumer goroutine pool for easy goroutine handling

finally released pool 2.0

##Pool v2 advantages over Pool v1:

  • Up to 300% faster due to lower contention ( BenchmarkSmallRun used to take 3 seconds, now 1 second )
  • Cancels are much faster
  • Easier to use, no longer need to know the # of Work Units to be processed.
  • Pool can now be used as a long running/globally defined pool if desired ( v1 Pool was only good for one run )
  • Supports single units of work as well as batching
  • Pool can easily be reset after a Close() or Cancel() for reuse.
  • Multiple Batches can be run and even cancelled on the same Pool.
  • Supports individual Work Unit cancellation.

A small suggestion

type Batch struct {
	pool    *Pool
	m       *sync.Mutex
	units   []*WorkUnit

The zero value for a sync.Mutex is usable. If you make this field a value, not a pointer, then you don’t have to initialise it in your constructor function.

You are correct, thanks :slight_smile: @dfc

OK got a little inspiration so v3 is released

now supports a limited consumer goroutine and unlimited goroutine pool

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.