MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / Close

Method Close

asyncbuffer/buffer.go:199–222  ·  view source on GitHub ↗

Close closes the AsyncBuffer and releases all resources. It is idempotent.

()

Source from the content-addressed store, hash-verified

197
198// Close closes the AsyncBuffer and releases all resources. It is idempotent.
199func (ab *AsyncBuffer) Close() error {
200 ab.mu.Lock()
201 defer ab.mu.Unlock()
202
203 // If the reader is already closed, we return immediately error or nil
204 if ab.closed.Load() {
205 return nil
206 }
207
208 ab.closed.Store(true)
209
210 // Return all chunks to the pool
211 for _, chunk := range ab.chunks {
212 chunkPool.Put(chunk)
213 }
214
215 // Release the paused latch so that no goroutines are waiting for it
216 ab.paused.Release()
217
218 // Finish downloading
219 ab.callFinishFn()
220
221 return nil
222}
223
224// Reader returns an io.ReadSeeker+io.ReaderAt that can be used to read actual data from the AsyncBuffer
225func (ab *AsyncBuffer) Reader() *Reader {

Callers 1

NewReadFullFunction · 0.95

Calls 3

callFinishFnMethod · 0.95
LoadMethod · 0.80
ReleaseMethod · 0.80

Tested by

no test coverage detected