Release implements Connection.
()
| 160 | |
| 161 | // Release implements Connection. |
| 162 | func (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. |
| 185 | func (c *connection) Slice(n int) (r Reader, err error) { |