Skip to content

DefaultFuture#doReceived should call done.signalAll instead of done.signal #3678

Closed

Description

@kexianjun

in the method of org.apache.dubbo.remoting.exchange.support.DefaultFuture#doReceived, I think we should call done.signalAll() instead of done.signal() ,and it's unnecessary to check done != null because it's always true

private void doReceived(Response res) {
        lock.lock();
        try {
            response = res;
            if (done != null) {
                done.signal();
            }
        } finally {
            lock.unlock();
        }
        if (callback != null) {
            invokeCallback(callback);
        }
    }

Activity

  1. changed the title [-]DefaultFuture#doReceived should call done.signalAll instead of done.signalAll[/-] [+]DefaultFuture#doReceived should call done.signalAll instead of done.signal[/+] on Mar 16, 2019
  2. tswstarplanet commented on Mar 16, 2019

    @tswstarplanet
    Contributor

    Sounds good! signall can avoid dead lock better

  3. kexianjun commented on Mar 16, 2019

    @kexianjun
    MemberAuthor

    Sounds good! signall can avoid dead lock better

    yes, using signal can cause threads to block until a timeout in some scenarios

  4. xueshanyinyan commented on Aug 28, 2020

    @xueshanyinyan

    阅读2.6.2版本的源码,觉得这个优化没必要吧,条件变量的等待队列里就一个线程,signal足够了,当然换成signalAll是没啥问题。是实际投入使用中出现了这样的问题吗?是什么样的问题呢?现在的版本已经使用CompletableFuture异步转同步了呢。

  5. LeroyPine commented on Mar 9, 2021

    @LeroyPine

    为什么 signal 或导致线程阻塞呢? DefaultFuture 不是和线程一一对应的。 不存在多线程竞争的关系吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions