7 // IteratorPool a thread safe pool of iterators with same configuration
8 type IteratorPool interface {
9 BorrowIterator(data []byte) *Iterator
10 ReturnIterator(iter *Iterator)
13 // StreamPool a thread safe pool of streams with same configuration
14 type StreamPool interface {
15 BorrowStream(writer io.Writer) *Stream
16 ReturnStream(stream *Stream)
19 func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream {
20 stream := cfg.streamPool.Get().(*Stream)
25 func (cfg *frozenConfig) ReturnStream(stream *Stream) {
28 stream.Attachment = nil
29 cfg.streamPool.Put(stream)
32 func (cfg *frozenConfig) BorrowIterator(data []byte) *Iterator {
33 iter := cfg.iteratorPool.Get().(*Iterator)
38 func (cfg *frozenConfig) ReturnIterator(iter *Iterator) {
41 cfg.iteratorPool.Put(iter)