You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/11/15 08:22:35 UTC
[GitHub] [dubbo] hanxueming126 opened a new issue #9276: 想请问下在消费端DubboInvoker在同步调用下线程问题
hanxueming126 opened a new issue #9276:
URL: https://github.com/apache/dubbo/issues/9276
<!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
<!-- For all design discussions please continue. -->
我看Dubbo3的源码,在默认Dubbo协议下,同步调用返回线程的时候是在`AbstractInvoker`中,同步状态下返回的是一个`ThreadlessExecutor`:
```java
protected ExecutorService getCallbackExecutor(URL url, Invocation inv) {
ExecutorService sharedExecutor = ExtensionLoader.getExtensionLoader(ExecutorRepository.class)
.getDefaultExtension()
.getExecutor(url);
if (InvokeMode.SYNC == RpcUtils.getInvokeMode(getUrl(), inv)) {
return new ThreadlessExecutor(sharedExecutor);
} else {
return sharedExecutor;
}
}
```
而我看`AbstractInvoker`里面的源码,这个里面维护了一个`BlockingQueue`队列,如果我们调用execute执行任务的时候会判断当前是否等待,如果等待将任务加入到队列中去。但是这里是每次调用都会生成一个`ThreadlessExecutor`,不太明白这么做的目的。
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] LiujunjieALiling commented on issue #9276: 想请问下在消费端DubboInvoker在同步调用下线程问题
Posted by GitBox <gi...@apache.org>.
LiujunjieALiling commented on issue #9276:
URL: https://github.com/apache/dubbo/issues/9276#issuecomment-986980749
> 我看Dubbo3的源码,在默认Dubbo协议下,同步调用返回线程的时候是在`AbstractInvoker`中,同步状态下返回的是一个`ThreadlessExecutor`:
>
> ```java
> protected ExecutorService getCallbackExecutor(URL url, Invocation inv) {
> ExecutorService sharedExecutor = ExtensionLoader.getExtensionLoader(ExecutorRepository.class)
> .getDefaultExtension()
> .getExecutor(url);
> if (InvokeMode.SYNC == RpcUtils.getInvokeMode(getUrl(), inv)) {
> return new ThreadlessExecutor(sharedExecutor);
> } else {
> return sharedExecutor;
> }
> }
> ```
>
> 而我看`AbstractInvoker`里面的源码,这个里面维护了一个`BlockingQueue`队列,如果我们调用execute执行任务的时候会判断当前是否等待,如果等待将任务加入到队列中去。但是这里是每次调用都会生成一个`ThreadlessExecutor`,不太明白这么做的目的。
这个是当调用侧 通过 future .get(),时才会使用到。 意思就是阻塞调用者,而不是占用线程池资源。 这个 `ThreadlessExecutor` 不是线程池
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org