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

Method addChunk

asyncbuffer/buffer.go:325–340  ·  view source on GitHub ↗

addChunk adds a new chunk to the AsyncBuffer, increments bytesRead and signals that a chunk is ready

(chunk *byteChunk)

Source from the content-addressed store, hash-verified

323// addChunk adds a new chunk to the AsyncBuffer, increments bytesRead
324// and signals that a chunk is ready
325func (ab *AsyncBuffer) addChunk(chunk *byteChunk) {
326 ab.mu.Lock()
327 defer ab.mu.Unlock()
328
329 if ab.closed.Load() {
330 // If the reader is closed, we return the chunk to the pool
331 chunkPool.Put(chunk)
332 return
333 }
334
335 // Store the chunk, increase chunk size, increase length of the data read
336 ab.chunks = append(ab.chunks, chunk)
337 ab.bytesRead.Add(int64(len(chunk.data)))
338
339 ab.chunkCond.Tick()
340}
341
342// readChunks reads data from the upstream reader in background and stores them in the pool
343func (ab *AsyncBuffer) readChunks() {

Callers 1

readChunksMethod · 0.95

Calls 3

LoadMethod · 0.80
AddMethod · 0.80
TickMethod · 0.80

Tested by

no test coverage detected