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

Method get

internal/transport/controlbuf.go:404–426  ·  view source on GitHub ↗

get returns the next control frame from the control buffer. If block is true **and** there are no control frames in the control buffer, the call blocks until one of the conditions is met: there is a frame to return or the transport is closed.

(block bool)

Source from the content-addressed store, hash-verified

402// until one of the conditions is met: there is a frame to return or the
403// transport is closed.
404func (c *controlBuffer) get(block bool) (any, error) {
405 for {
406 c.mu.Lock()
407 frame, err := c.getOnceLocked()
408 if frame != nil || err != nil || !block {
409 // If we read a frame or an error, we can return to the caller. The
410 // call to getOnceLocked() returns a nil frame and a nil error if
411 // there is nothing to read, and in that case, if the caller asked
412 // us not to block, we can return now as well.
413 c.mu.Unlock()
414 return frame, err
415 }
416 c.consumerWaiting = true
417 c.mu.Unlock()
418
419 // Release the lock above and wait to be woken up.
420 select {
421 case <-c.wakeupCh:
422 case <-c.done:
423 return nil, errors.New("transport closed by client")
424 }
425 }
426}
427
428// Callers must not use this method, but should instead use get().
429//

Callers 1

runMethod · 0.45

Calls 3

getOnceLockedMethod · 0.95
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected