MCPcopy
hub / github.com/dropbox/godropbox / writeLoop

Method writeLoop

io2/pipelined_copy.go:198–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

196}
197
198func (c *circularBufferCopier) writeLoop() {
199 for {
200 var buf *buffer
201 select {
202 case buf = <-c.readyChan:
203 // do nothing
204 case <-c.earlyExitChan:
205 c.errChan <- nil
206 return
207 }
208
209 if buf.size > 0 {
210 written, err := c.dest.Write(buf.array[0:buf.size])
211
212 c.numWritten += int64(written)
213
214 if err != nil {
215 c.errChan <- errors.Wrap(
216 err,
217 "Failed to write to destination: ")
218 return
219 }
220
221 if written != buf.size {
222 c.errChan <- errors.New(
223 "Failed to write to destination: short write")
224 return
225 }
226
227 if fl, ok := c.dest.(http.Flusher); ok {
228 fl.Flush()
229 }
230 }
231
232 if buf.eof {
233 c.errChan <- nil
234 return
235 }
236
237 c.recycleChan <- buf.array
238 }
239}

Callers 4

executeMethod · 0.95
TestBasicWriteMethod · 0.80
TestWriteErrorMethod · 0.80
TestWriteEarlyExitMethod · 0.80

Calls 4

WrapFunction · 0.92
NewFunction · 0.92
FlushMethod · 0.65
WriteMethod · 0.45

Tested by 3

TestBasicWriteMethod · 0.64
TestWriteErrorMethod · 0.64
TestWriteEarlyExitMethod · 0.64