wuyunfeng commented on pull request #5336: URL: https://github.com/apache/incubator-doris/pull/5336#issuecomment-786450377
I just using `Java` describe the implementation which I would prefer: First define a `NoOpLock`: ``` protected static final class NoOpLock implements Lock { @Override public void lock() { } @Override public void lockInterruptibly() throws InterruptedException { } @Override public boolean tryLock() { return true; } @Override public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { return true; } @Override public void unlock() { } @Override public Condition newCondition() { throw new UnsupportedOperationException("NoOpLock can't provide a condition"); } } ``` We just define a `private final Lock lock = new NoOpLock();` If using `async` mode, let the lock using the real `Lock`, If not, we can replace the `lock` with `NoOpLock`. If we do this, the first code is more elegant, and second, we can avoid excessive branch switching. I think your approach is fine, would you like to think about my suggestion ---------------------------------------------------------------- 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 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org