pnowojski commented on a change in pull request #10009: [FLINK-14304] Avoid 
task starvation with mailbox
URL: https://github.com/apache/flink/pull/10009#discussion_r341120305
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/mailbox/TaskMailboxImpl.java
 ##########
 @@ -172,13 +172,17 @@ private Mail takeHeadInternal(int priority) throws 
IllegalStateException {
                return null;
        }
 
-       private void drainAllMails(List<Runnable> drainInto) {
-               assert lock.isHeldByCurrentThread();
-               for (Mail mail : queue) {
-                       drainInto.add(mail.getRunnable());
+       @Override
+       public List<Mail> drain() {
+               final ReentrantLock lock = this.lock;
+               lock.lock();
 
 Review comment:
   isn't double acquiring the lock hurting performance?
   
   Usually the pattern that we follow, is to provide synchronized `public` 
method, with non synchronized/unsafe `private` counterpart (usually with 
`Unsafe` suffix added to the method name, here that would be `private 
List<Mail> drainUnsafe()`) for re-using in other public methods. 

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