1u0 commented on a change in pull request #9383: [FLINK-13248] [runtime] Adding 
processing of downstream messages in AsyncWaitOperator's wait loops
URL: https://github.com/apache/flink/pull/9383#discussion_r314741672
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/mailbox/TaskMailboxImpl.java
 ##########
 @@ -251,4 +278,74 @@ public void quiesce() {
        public State getState() {
                return state;
        }
+
+       @Override
+       public Mailbox getDownstreamMailbox(int priority) {
+               return new DownstreamMailbox(priority);
+       }
+
+       class DownstreamMailbox implements Mailbox {
+               private final int priority;
+
+               DownstreamMailbox(int priority) {
+                       this.priority = priority;
+               }
+
+               @Override
+               public boolean hasMail() {
+                       lock.lock();
+                       try {
+                               for (Mail mail : queue) {
+                                       if (mail.getOperatorIndex() >= 
priority) {
+                                               return true;
+                                       }
+                               }
+                               return false;
+                       } finally {
+                               lock.unlock();
+                       }
+               }
+
+               @Override
+               public Optional<Runnable> tryTakeMail() throws 
MailboxStateException {
+                       return tryTakeDownstreamMail(priority);
+               }
+
+               @Nonnull
+               @Override
+               public Runnable takeMail() throws InterruptedException, 
MailboxStateException {
+                       return takeDownstreamMail(priority);
+               }
+
+               @Override
+               public void putMail(@Nonnull Runnable letter) throws 
MailboxStateException {
+                       TaskMailboxImpl.this.putMail(letter, priority);
+               }
+
+               @Override
+               public void putFirst(@Nonnull Runnable priorityLetter) throws 
MailboxStateException {
+                       TaskMailboxImpl.this.putFirst(priorityLetter, priority);
+               }
+       }
+
+       /**
+        * An executable bound to a specific operator in the chain, such that 
it can be picked for downstream mailbox.
+        */
+       static class Mail {
+               private final Runnable runnable;
+               private final int operatorIndex;
 
 Review comment:
   Rename the field (and the corresponding method) to `priority`?

----------------------------------------------------------------
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