zhijiangW commented on a change in pull request #9993: 
[FLINK-14498][runtime]Introduce NetworkBufferPool#isAvailable() for interacting 
with LocalBufferPool.
URL: https://github.com/apache/flink/pull/9993#discussion_r339029685
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/LocalBufferPool.java
 ##########
 @@ -231,18 +231,43 @@ private BufferBuilder toBufferBuilder(MemorySegment 
memorySegment) {
 
        @Nullable
        private MemorySegment requestMemorySegment(boolean isBlocking) throws 
InterruptedException, IOException {
+               // a flag to indicate whether the blocking request thread is
+               // waiting and needs to be notified
+               final AtomicBoolean waitingFlag = new AtomicBoolean(false);
                MemorySegment segment = null;
                synchronized (availableMemorySegments) {
                        returnExcessMemorySegments();
 
                        // fill availableMemorySegments with at least one 
element, wait if required
                        while (availableMemorySegments.isEmpty()) {
                                segment = requestMemorySegmentFromGlobal();
-                               if (segment != null || !isBlocking) {
+                               if (segment != null || !isBlocking || 
!availableMemorySegments.isEmpty()) {
 
 Review comment:
   `!availableMemorySegments.isEmpty()` is not very necessary? Because it is 
duplicated with the condition in above `while 
(availableMemorySegments.isEmpty())`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to