MCPcopy Create free account
hub / github.com/cloudwego/netpoll / Write

Method Write

connection_impl.go:338–353  ·  view source on GitHub ↗

Write will Flush soon.

(p []byte)

Source from the content-addressed store, hash-verified

336
337// Write will Flush soon.
338func (c *connection) Write(p []byte) (n int, err error) {
339 if !c.IsActive() {
340 return 0, Exception(ErrConnClosed, "when write")
341 }
342
343 if !c.lock(flushing) {
344 return 0, Exception(ErrConcurrentAccess, "when write")
345 }
346 defer c.unlock(flushing)
347
348 dst, _ := c.outputBuffer.Malloc(len(p))
349 n = copy(dst, p)
350 c.outputBuffer.Flush()
351 err = c.flush()
352 return n, err
353}
354
355// Close implements Connection.
356func (c *connection) Close() error {

Callers 5

TestConnectionWriteFunction · 0.95
TestConnectionReadFunction · 0.95
TestConnectionUntilFunction · 0.95
TestPollManagerFunction · 0.95

Calls 7

IsActiveMethod · 0.95
flushMethod · 0.95
ExceptionFunction · 0.85
MallocMethod · 0.65
FlushMethod · 0.65
lockMethod · 0.45
unlockMethod · 0.45

Tested by 5

TestConnectionWriteFunction · 0.76
TestConnectionReadFunction · 0.76
TestConnectionUntilFunction · 0.76
TestPollManagerFunction · 0.76