MCPcopy
hub / github.com/grpc/grpc-go / add

Method add

internal/transport/bdp_estimator.go:85–100  ·  view source on GitHub ↗

add adds bytes to the current sample for calculating bdp. It returns true only if a ping must be sent. This can be used by the caller (handleData) to make decision about batching a window update with it.

(n uint32)

Source from the content-addressed store, hash-verified

83// by the caller (handleData) to make decision about batching
84// a window update with it.
85func (b *bdpEstimator) add(n uint32) bool {
86 b.mu.Lock()
87 defer b.mu.Unlock()
88 if b.bdp == bdpLimit {
89 return false
90 }
91 if !b.isSent {
92 b.isSent = true
93 b.sample = n
94 b.sentAt = time.Time{}
95 b.sampleCount++
96 return true
97 }
98 b.sample += n
99 return false
100}
101
102// calculate is called when an ack for a bdp ping is received.
103// Here we calculate the current bdp and bandwidth sample and

Callers 2

handleDataMethod · 0.45
handleDataMethod · 0.45

Calls 2

LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected