We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://github.com/apache/dubbo/blob/dubbo-2.7.8/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java
private final AtomicBoolean started = new AtomicBoolean(false); private CompletableFuture<Object> future; public void start() { if (this.started.compareAndSet(false, true)) { this.future = new CompletableFuture<>(); } } public void write(Object value) { if (isAsyncStarted() && stop()) { if (value instanceof Throwable) { Throwable bizExe = (Throwable) value; future.completeExceptionally(bizExe); } else { future.complete(value); } } else { // ignored } }
当isAsyncStarted()返回true时确定能保证future字段的可见性么?
isAsyncStarted()
The text was updated successfully, but these errors were encountered:
为了确保 future 字段在被多个线程访问时的可见性和一致性,您可以将其声明为 volatile,或者使用适当的同步机制(如同步块或 Lock 对象)在 future 字段的写入和读取操作之间建立发生之前关系 。
Sorry, something went wrong.
No branches or pull requests
https://github.com/apache/dubbo/blob/dubbo-2.7.8/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AsyncContextImpl.java
当
isAsyncStarted()
返回true时确定能保证future字段的可见性么?The text was updated successfully, but these errors were encountered: