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

Method Wait

asyncbuffer/buffer.go:154–175  ·  view source on GitHub ↗

Wait waits for the reader to finish reading all data and returns the total length of the data read.

()

Source from the content-addressed store, hash-verified

152// Wait waits for the reader to finish reading all data and returns
153// the total length of the data read.
154func (ab *AsyncBuffer) Wait() (int, error) {
155 // Wait ends till the end of the stream: unpause the reader
156 ab.paused.Release()
157
158 // Get initial cursor before first check
159 cursor := ab.chunkCond.Cursor()
160
161 for {
162 // We can not read data from the closed reader
163 if err := ab.closedError(); err != nil {
164 return 0, err
165 }
166
167 // In case the reader is finished reading, we can return immediately
168 if ab.finished.Load() {
169 return int(ab.bytesRead.Load()), ab.Error()
170 }
171
172 // Lock until the next chunk is ready
173 cursor = ab.chunkCond.Wait(cursor)
174 }
175}
176
177// ReleaseThreshold releases the pause, allowing the buffer to immediately
178// read data beyond the pause threshold.

Callers 2

WaitForMethod · 0.45
readChunksMethod · 0.45

Calls 5

closedErrorMethod · 0.95
ErrorMethod · 0.95
ReleaseMethod · 0.80
CursorMethod · 0.80
LoadMethod · 0.80

Tested by

no test coverage detected