onRead is invoked when the application reads the data. It returns the window size to be sent to the peer.
(n uint32)
| 187 | // onRead is invoked when the application reads the data. It returns the window size |
| 188 | // to be sent to the peer. |
| 189 | func (f *inFlow) onRead(n uint32) uint32 { |
| 190 | f.mu.Lock() |
| 191 | defer f.mu.Unlock() |
| 192 | |
| 193 | if f.pendingData == 0 { |
| 194 | return 0 |
| 195 | } |
| 196 | f.pendingData -= n |
| 197 | if n > f.delta { |
| 198 | n -= f.delta |
| 199 | f.delta = 0 |
| 200 | } else { |
| 201 | f.delta -= n |
| 202 | n = 0 |
| 203 | } |
| 204 | f.pendingUpdate += n |
| 205 | if f.pendingUpdate >= f.limit/4 { |
| 206 | wu := f.pendingUpdate |
| 207 | f.pendingUpdate = 0 |
| 208 | return wu |
| 209 | } |
| 210 | return 0 |
| 211 | } |
no test coverage detected