Là một dự án backend, electronicarts/ea-async đã đạt 1.4k sao trên GitHub, ngôn ngữ Java. EA Async implements async-await methods in the JVM.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
EA Async implements Async-Await methods in the JVM.
It allows programmers to write asynchronous code in a sequential fashion.
It is heavily inspired by Async-Await on the .NET CLR, see Asynchronous Programming with Async and Await for more information.
Who should use it?
EA Async should be used to write non-blocking asynchronous code that makes heavy use of CompletableFutures or CompletionStage.
It improves scalability by freeing worker threads while your code awaits other processes;
And improves productivity by making asynchronous code simpler and more readable.
Developer & License
This project was developed by Electronic Arts and is licensed under the BSD 3-Clause License.
Examples
With EA Async
import static com.ea.async.Async.await;
import static java.util.concurrent.CompletableFuture.completedFuture;
public class Store
{
public CompletableFuture<Boolean> buyItem(String itemTypeId, int cost)
{
if(!await(bank.decrement(cost))) {
return completedFuture(false);
}
await(inventory.giveItem(itemTypeId));
return completedFuture(true);
}
}
In this example Bank.decrement returns CompletableFuture<Boolean> and Inventory.giveItem returns CompletableFuture<String>
EA Async rewrites the calls to Async.await making your methods non-blocking.
The methods look blocking but are actually transformed into asynchronous methods that use
CompletableFutures to continue the execution as intermediary results arrive.
Without EA Async
This is how the first example looks without EA Async. It is a bit less readable.
import static java.util.concurrent.CompletableFuture.completedFuture;
public class Store
{
public CompletableFuture<Boolean> buyItem(String itemTypeId, int cost)
{
return bank.decrement(cost)
.thenCompose(result -> {
if(!result) {
return completedFuture(false);
}
return inventory.giveItem(itemTypeId).thenApply(res -> true);
});
}
}
This is a small example... A method with a few more CompletableFutures can look very convoluted.
EA Async abstracts away the complexity of the CompletableFutures.
With EA Async (2)
So you like CompletableFutures?
Try converting this method to use only CompletableFutures without ever blocking (so no joining):
import static com.ea.async.Async.await;
import static java.util.concurrent.CompletableFuture.completedFuture;
public class Store
{
public CompletableFuture<Boolean> buyItem(String itemTypeId, int cost)
{
if(!await(bank.decrement(cost))) {
return completedFuture(false);
}
try {
await(inventory.giveItem(itemTypeId));
return completedFuture(true);
} catch (Exception ex) {
await(bank.refund(cost));
throw new AppException(ex);
}
}
}
Got it? Send it to us. It probably looks ugly...
Getting started
EA Async currently supports JDK 8-10.
It works with Java and Scala and should work with most JVM languages.
The only requirement to use EA Async is that must be used only inside methods that return CompletableFuture, CompletionStage, or subclasses of CompletableFuture.
It's recommended to add this as a default option to launchers in IntelliJ projects that use ea-async.
Option 2 - Runtime
On your main class or as early as possible, call at least once:
Async.init();
Provided that your JVM has the capability enabled, this will start a runtime instrumentation agent.
If you forget to invoke this function, the first call to await will initialize the system (and print a warning).
This is a solution for testing and development, it has the least amount of configuration.
It might interfere with JVM debugging. This alternative is present as a fallback.
Option 3 - Run instrumentation tool
The ea-async-1.2.3.jar is a runnable jar that can pre-instrument your files.
After that all the files in target/classes will have been instrumented.
There will be no references to Async.await and Async.init left in those classes.
Option 4 - Build time instrumentation, with Maven - Preferred
Use the ea-async-maven-plugin. It will instrument your classes in compile time and
remove all references to Async.await and Async.init().
With build time instrumentation your project users won't need to have EA Async in their classpath unless they also choose to use it.
This means that EA Async does not need to be a transitive dependency.
This is the best option for libraries and maven projects.
electronicarts/ea-async thuộc nhóm Backend trên TopGit, cùng 7 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về electronicarts/ea-async ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/electronicarts/ea-async là nguồn chính thức.
electronicarts/ea-async có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho electronicarts/ea-async. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
electronicarts/ea-async có trang demo không?
Dự án có trang chủ ở https://go.ea.com/ea-async. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
electronicarts/ea-async là gì?
electronicarts/ea-async (electronicarts/ea-async) là dự án Java trên GitHub. Theo mô tả gốc: EA Async implements async-await methods in the JVM.
Vì sao electronicarts/ea-async được xếp vào nhóm Backend?
TopGit xếp electronicarts/ea-async vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "async", "async-await", "asynchronous"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
ea-async có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về ea-async.