diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/golang.org/x/net/http2/flow.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/golang.org/x/net/http2/flow.go')
-rw-r--r-- | vendor/golang.org/x/net/http2/flow.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/vendor/golang.org/x/net/http2/flow.go b/vendor/golang.org/x/net/http2/flow.go new file mode 100644 index 0000000..957de25 --- /dev/null +++ b/vendor/golang.org/x/net/http2/flow.go | |||
@@ -0,0 +1,50 @@ | |||
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. | ||
4 | |||
5 | // Flow control | ||
6 | |||
7 | package http2 | ||
8 | |||
9 | // flow is the flow control window's size. | ||
10 | type flow struct { | ||
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. | ||
13 | n int32 | ||
14 | |||
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. | ||
18 | conn *flow | ||
19 | } | ||
20 | |||
21 | func (f *flow) setConnFlow(cf *flow) { f.conn = cf } | ||
22 | |||
23 | func (f *flow) available() int32 { | ||
24 | n := f.n | ||
25 | if f.conn != nil && f.conn.n < n { | ||
26 | n = f.conn.n | ||
27 | } | ||
28 | return n | ||
29 | } | ||
30 | |||
31 | func (f *flow) take(n int32) { | ||
32 | if n > f.available() { | ||
33 | panic("internal error: took too much") | ||
34 | } | ||
35 | f.n -= n | ||
36 | if f.conn != nil { | ||
37 | f.conn.n -= n | ||
38 | } | ||
39 | } | ||
40 | |||
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 | ||
45 | if n > remain { | ||
46 | return false | ||
47 | } | ||
48 | f.n += n | ||
49 | return true | ||
50 | } | ||