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

Method Release

connection_impl.go:162–182  ·  view source on GitHub ↗

Release implements Connection.

()

Source from the content-addressed store, hash-verified

160
161// Release implements Connection.
162func (c *connection) Release() (err error) {
163 // Check inputBuffer length first to reduce contention in mux situation.
164 // c.operator.do competes with c.inputs/c.inputAck
165 if c.inputBuffer.Len() == 0 && c.operator.do() {
166 maxSize := c.inputBuffer.calcMaxSize()
167 // Set the maximum value of maxsize equal to mallocMax to prevent GC pressure.
168 if maxSize > mallocMax {
169 maxSize = mallocMax
170 }
171
172 if maxSize > c.maxSize {
173 c.maxSize = maxSize
174 }
175 // Double check length to reset tail node
176 if c.inputBuffer.Len() == 0 {
177 c.inputBuffer.resetTail(c.maxSize)
178 }
179 c.operator.done()
180 }
181 return c.inputBuffer.Release()
182}
183
184// Slice implements Connection.
185func (c *connection) Slice(n int) (r Reader, err error) {

Callers 1

TestConnectionIOReaderFunction · 0.95

Calls 6

doMethod · 0.80
doneMethod · 0.80
LenMethod · 0.65
ReleaseMethod · 0.65
calcMaxSizeMethod · 0.45
resetTailMethod · 0.45

Tested by 1

TestConnectionIOReaderFunction · 0.76