aboutsummaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/grpc/transport/control.go
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2016-12-28 21:18:36 +0000
committerNiall Sheridan <nsheridan@gmail.com>2016-12-28 21:18:36 +0000
commit73ef85bc5db590c22689e11be20737a3dd88168f (patch)
treefe393a6f0776bca1889b2113ab341a2922e25d10 /vendor/google.golang.org/grpc/transport/control.go
parent9e573e571fe878ed32947cae5a6d43cb5d72d3bb (diff)
Update dependencies
Diffstat (limited to 'vendor/google.golang.org/grpc/transport/control.go')
-rw-r--r--vendor/google.golang.org/grpc/transport/control.go34
1 files changed, 6 insertions, 28 deletions
diff --git a/vendor/google.golang.org/grpc/transport/control.go b/vendor/google.golang.org/grpc/transport/control.go
index 4ef0830..2586cba 100644
--- a/vendor/google.golang.org/grpc/transport/control.go
+++ b/vendor/google.golang.org/grpc/transport/control.go
@@ -111,35 +111,9 @@ func newQuotaPool(q int) *quotaPool {
return qb
}
-// add adds n to the available quota and tries to send it on acquire.
-func (qb *quotaPool) add(n int) {
- qb.mu.Lock()
- defer qb.mu.Unlock()
- qb.quota += n
- if qb.quota <= 0 {
- return
- }
- select {
- case qb.c <- qb.quota:
- qb.quota = 0
- default:
- }
-}
-
-// cancel cancels the pending quota sent on acquire, if any.
-func (qb *quotaPool) cancel() {
- qb.mu.Lock()
- defer qb.mu.Unlock()
- select {
- case n := <-qb.c:
- qb.quota += n
- default:
- }
-}
-
-// reset cancels the pending quota sent on acquired, incremented by v and sends
+// add cancels the pending quota sent on acquired, incremented by v and sends
// it back on acquire.
-func (qb *quotaPool) reset(v int) {
+func (qb *quotaPool) add(v int) {
qb.mu.Lock()
defer qb.mu.Unlock()
select {
@@ -151,6 +125,10 @@ func (qb *quotaPool) reset(v int) {
if qb.quota <= 0 {
return
}
+ // After the pool has been created, this is the only place that sends on
+ // the channel. Since mu is held at this point and any quota that was sent
+ // on the channel has been retrieved, we know that this code will always
+ // place any positive quota value on the channel.
select {
case qb.c <- qb.quota:
qb.quota = 0