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

Function New

asyncbuffer/buffer.go:86–98  ·  view source on GitHub ↗

New creates a new AsyncBuffer that reads from the given io.ReadCloser in background and closes it when finished. r - io.ReadCloser to read data from dataLen - expected length of the data in r, <= 0 means unknown length finishFn - optional functions to call when the buffer is finished reading

(r io.ReadCloser, dataLen int, finishFn ...context.CancelFunc)

Source from the content-addressed store, hash-verified

84// dataLen - expected length of the data in r, <= 0 means unknown length
85// finishFn - optional functions to call when the buffer is finished reading
86func New(r io.ReadCloser, dataLen int, finishFn ...context.CancelFunc) *AsyncBuffer {
87 ab := &AsyncBuffer{
88 r: r,
89 dataLen: dataLen,
90 paused: NewLatch(),
91 chunkCond: NewCond(),
92 finishFn: finishFn,
93 }
94
95 go ab.readChunks()
96
97 return ab
98}
99
100// NewReadFull creates a new AsyncBuffer that reads from the given io.ReadCloser
101// in foreground, blocking until all data is read. It returns an error if reading

Calls 3

readChunksMethod · 0.95
NewLatchFunction · 0.85
NewCondFunction · 0.85