https://github.com/koykov/lbpool
Pool based on leaky buffer template.
https://github.com/koykov/lbpool
leaky-buffer pool
Last synced: about 1 month ago
JSON representation
Pool based on leaky buffer template.
- Host: GitHub
- URL: https://github.com/koykov/lbpool
- Owner: koykov
- License: mit
- Created: 2020-01-16T21:36:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-23T19:32:19.000Z (almost 3 years ago)
- Last Synced: 2025-09-01T12:51:09.933Z (5 months ago)
- Topics: leaky-buffer, pool
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Leaky Buffer pool
A pool solution that implements [leaky buffer](https://golang.org/doc/effective_go.html#leaky_buffer) template.
It's slowly than vanilla pool but implements release logic in other hand. [sync/pool](https://golang.org/src/sync/pool.go) is a great pool solution
but it has a big inconvenience
> Any item stored in the Pool may be removed automatically at any time without
notification. If the Pool holds the only reference when this happens, the
item might be deallocated.
> - https://golang.org/src/sync/pool.go
This pool was made special for object like [cbyte](https://github.com/koykov/cbyte) that requires manual release.
Use it the same as vanilla pools.
## Benchmarks
```
BenchmarkPool-8 20000000 81.8 ns/op 0 B/op 0 allocs/op
BenchmarkPoolParallel-8 100000000 19.6 ns/op 0 B/op 0 allocs/op
BenchmarkPoolNative-8 50000000 25.6 ns/op 0 B/op 0 allocs/op
BenchmarkPoolNativeParallel-8 200000000 5.54 ns/op 0 B/op 0 allocs/op
```
LB pool is 4-5 slowest that vanilla since it based on channels, whereas native is based on system pins.