Skip to content

Commit 65ae2ef

Browse files
committed
examples: Reflow manualflowcontrol; check isReady() earlier
This change is mostly to flow the paragraph across multiple lines like all other text in this file. But I did also replace checking for isReady() before calling onNext() with checking before creating messages. If you already have the message created, it doesn't change much to go ahead and enqueue it, but don't go create another message immediately.
1 parent 16e17ab commit 65ae2ef

File tree

1 file changed

+7
-1
lines changed
  • examples/src/main/java/io/grpc/examples/manualflowcontrol

1 file changed

+7
-1
lines changed

examples/src/main/java/io/grpc/examples/manualflowcontrol/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ value.
2525

2626
### Outgoing Flow Control
2727

28-
The underlying layer (such as Netty) manages a buffer for outgoing messages. If you write messages faster than they can be sent over the network, this buffer will grow, which can eventually lead to an OutOfMemoryError. The outgoing onNext method invocation does not block when this happens. Therefore, you should explicitly check that the stream is ready for writing via `CallStreamObserver.isReady()` before calling onNext to avoid buffering excessive amounts of data in memory.
28+
The underlying layer (such as Netty) manages a buffer for outgoing messages. If
29+
you write messages faster than they can be sent over the network, this buffer
30+
will grow, which can eventually lead to an OutOfMemoryError. The outgoing onNext
31+
method invocation does not block when this happens. Therefore, you should
32+
explicitly check that the stream is ready for writing via
33+
`CallStreamObserver.isReady()` before generating messages to avoid buffering
34+
excessive amounts of data in memory.
2935

3036
### Incoming Manual Flow Control
3137

0 commit comments

Comments
 (0)