1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 // flow is the flow control window's size.
11 // n is the number of DATA bytes we're allowed to send.
12 // A flow is kept both on a conn and a per-stream.
15 // conn points to the shared connection-level flow that is
16 // shared by all streams on that conn. It is nil for the flow
17 // that's on the conn directly.
21 func (f *flow) setConnFlow(cf *flow) { f.conn = cf }
23 func (f *flow) available() int32 {
25 if f.conn != nil && f.conn.n < n {
31 func (f *flow) take(n int32) {
32 if n > f.available() {
33 panic("internal error: took too much")
41 // add adds n bytes (positive or negative) to the flow control window.
42 // It returns false if the sum would exceed 2^31-1.
43 func (f *flow) add(n int32) bool {
44 remain := (1<<31 - 1) - f.n