// GetBounded creates a bounded buffer of the given size.
GetBounded creates a bounded buffer of the given size.
// GetBounded creates a bounded buffer of the given size .
func (p *Pool) GetBounded(size int64) (buffer.BufferAt, error) {
	var buffers []buffer.BufferAt
	filesCount := size / p.fileSize
	if size%p.fileSize > 0 {
		filesCount++
	}
	cleanup := func() {
		for _, f := range buffers {
			_ = p.filePool.Put(f)
		}
	}
	for i := 0; i < int(filesCount); i++ {
		file, err := p.filePool.Get()
		if err != nil {
			cleanup()
			return nil, err
		}
		buffers = append(buffers, file.(buffer.BufferAt))
	}
	return &boundedFileBuffer{Files: buffers, BufferAt: buffer.NewMultiAt(buffers...)}, nil
}
func ( p * Pool ) GetBounded ( size int64 ) ( buffer . BufferAt , error ) { var buffers [ ] buffer . BufferAt filesCount := size / p . fileSize if size % p . fileSize > 0 { filesCount ++ } cleanup := func ( ) { for _ , f := range buffers { _ = p . filePool . Put ( f ) } } for i := 0 ; i < int ( filesCount ) ; i ++ { file , err := p . filePool . Get ( ) if err != nil { cleanup ( ) return nil , err } buffers = append ( buffers , file . ( buffer . BufferAt ) ) } return & boundedFileBuffer { Files : buffers , BufferAt : buffer . NewMultiAt ( buffers ... ) } , nil }
GetBounded creates a bounded buffer of the given size.
GetBounded creates a bounded buffer of the given size .