pnowojski commented on a change in pull request #8692: [FLINK-12804] Introduce 
mailbox-based ExecutorService
URL: https://github.com/apache/flink/pull/8692#discussion_r302953532
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/mailbox/MailboxImpl.java
 ##########
 @@ -38,39 +40,44 @@
 public class MailboxImpl implements Mailbox {
 
        /**
-        * The enqueued letters.
+        * Node for the embedded linked list that represents the mailbox queue.
         */
-       @GuardedBy("lock")
-       private final Runnable[] ringBuffer;
+       static final class Node {
 
-       /**
-        * Lock for all concurrent ops.
-        */
-       private final ReentrantLock lock;
+               /** The payload. */
+               final Runnable letter;
+
+               /** Link to the next node in the list. */
+               @Nullable
+               Node next;
+
+               Node(Runnable letter) {
+                       this.letter = letter;
+               }
+       }
 
        /**
-        * Condition that is triggered when the buffer is no longer empty.
+        * The head of the linked list of mailbox actions.
         */
-       @GuardedBy("lock")
-       private final Condition notEmpty;
+       @Nullable
+       private Node head;
 
        /**
-        * Condition that is triggered when the buffer is no longer full.
+        * The tail of the linked list of mailbox actions.
         */
-       @GuardedBy("lock")
-       private final Condition notFull;
+       @Nullable
+       private Node tail;
 
        /**
-        * Index of the ring buffer head.
+        * Lock for all concurrent ops.
         */
-       @GuardedBy("lock")
-       private int headIndex;
+       private final ReentrantLock lock;
 
        /**
-        * Index of the ring buffer tail.
+        * Condition that is triggered when the buffer is no longer empty.
 
 Review comment:
   `buffer` is no longer relevant. Java doc's link (`{@link #ringBuffer}`) 
would have guarded against that.
   
   Extracting linked list to a separate class/using `LinkedList` would also 
allow to keep the java doc link to a new field.
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to