Skip to content

FelixSeptem/sizepool

Repository files navigation

sizepool

A fix size of pool for Go

Build Status Coverage Status Go Report Card GoDoc GolangCI

The difference between sync.Pool

sync.Pool is aimed at to to cache allocated but unused items for later reuse, relieving pressure on the garbage collector. And the sizepool is aimed at preallocate a fix size of object size in order to cache a pool of the object(in a list). You can Get and Put object into pool just like use sync.Pool,the difference is the sync.Pool won't block when the pool is empty, it will allocated a new object. But the sizepool will be blocked (or return ErrNoEnoughItem immediately, depends on you use BGet or Get). Also, object in sync.Pool may be garbage collect,and object in sizepool won't be garbage collect. The thing to be notice is that the size of sizepool may not be constant, if your call more time Put than Get and BGet, your sizepool will have the bigger size than your given init size.(resolved)

About

A fix size of pool for Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages