[ 
https://issues.apache.org/jira/browse/GROOVY-9381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18033039#comment-18033039
 ] 

ASF GitHub Bot commented on GROOVY-9381:
----------------------------------------

codecov-commenter commented on PR #2324:
URL: https://github.com/apache/groovy/pull/2324#issuecomment-3448631653

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2324?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `74.84663%` with `41 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 67.0124%. Comparing base 
([`4e0dc1a`](https://app.codecov.io/gh/apache/groovy/commit/4e0dc1a180e2d37464ff17bd3375a08a1607e3d6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`208111a`](https://app.codecov.io/gh/apache/groovy/commit/208111a94bf06d5e9e63e4a3cb4fa8084598d95d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2324?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...va/groovy/util/concurrent/async/SimplePromise.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FSimplePromise.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL1NpbXBsZVByb21pc2UuamF2YQ==)
 | 83.3333% | [16 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...a/groovy/util/concurrent/async/AwaitException.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FAwaitException.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL0F3YWl0RXhjZXB0aW9uLmphdmE=)
 | 25.0000% | [6 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...java/groovy/util/concurrent/async/AsyncHelper.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FAsyncHelper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL0FzeW5jSGVscGVyLmphdmE=)
 | 66.6667% | [5 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...ain/java/groovy/util/concurrent/async/Promise.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FPromise.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL1Byb21pc2UuamF2YQ==)
 | 0.0000% | [5 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...a/groovy/util/concurrent/async/StageAwaitable.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FStageAwaitable.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL1N0YWdlQXdhaXRhYmxlLmphdmE=)
 | 0.0000% | [5 Missing :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...ehaus/groovy/transform/AsyncASTTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FAsyncASTTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9Bc3luY0FTVFRyYW5zZm9ybWF0aW9uLmphdmE=)
 | 83.3333% | [2 Missing and 2 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/2324/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2324        +/-   ##
   ==================================================
   + Coverage     67.0088%   67.0124%   +0.0035%     
   - Complexity      29326      29399        +73     
   ==================================================
     Files            1382       1388         +6     
     Lines          116604     116765       +161     
     Branches        20427      20430         +3     
   ==================================================
   + Hits            78135      78247       +112     
   - Misses          32036      32079        +43     
   - Partials         6433       6439         +6     
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/2324?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Δ | |
   |---|---|---|
   | 
[...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAstBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0FzdEJ1aWxkZXIuamF2YQ==)
 | `86.6637% <100.0000%> (+0.0415%)` | :arrow_up: |
   | 
[...g/apache/groovy/parser/antlr4/ModifierManager.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FModifierManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L01vZGlmaWVyTWFuYWdlci5qYXZh)
 | `93.4210% <100.0000%> (ø)` | |
   | 
[...ain/java/org/codehaus/groovy/ast/ModifierNode.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FModifierNode.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9Nb2RpZmllck5vZGUuamF2YQ==)
 | `77.7778% <100.0000%> (+0.4193%)` | :arrow_up: |
   | 
[...ehaus/groovy/transform/AsyncASTTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FAsyncASTTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9Bc3luY0FTVFRyYW5zZm9ybWF0aW9uLmphdmE=)
 | `83.3333% <83.3333%> (ø)` | |
   | 
[...java/groovy/util/concurrent/async/AsyncHelper.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FAsyncHelper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL0FzeW5jSGVscGVyLmphdmE=)
 | `66.6667% <66.6667%> (ø)` | |
   | 
[...ain/java/groovy/util/concurrent/async/Promise.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FPromise.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL1Byb21pc2UuamF2YQ==)
 | `0.0000% <0.0000%> (ø)` | |
   | 
[...a/groovy/util/concurrent/async/StageAwaitable.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FStageAwaitable.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL1N0YWdlQXdhaXRhYmxlLmphdmE=)
 | `0.0000% <0.0000%> (ø)` | |
   | 
[...a/groovy/util/concurrent/async/AwaitException.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FAwaitException.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL0F3YWl0RXhjZXB0aW9uLmphdmE=)
 | `25.0000% <25.0000%> (ø)` | |
   | 
[...va/groovy/util/concurrent/async/SimplePromise.java](https://app.codecov.io/gh/apache/groovy/pull/2324?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Futil%2Fconcurrent%2Fasync%2FSimplePromise.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvdXRpbC9jb25jdXJyZW50L2FzeW5jL1NpbXBsZVByb21pc2UuamF2YQ==)
 | `83.3333% <83.3333%> (ø)` | |
   
   ... and [4 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/2324/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> Support async/await like ES7
> ----------------------------
>
>                 Key: GROOVY-9381
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9381
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Daniel Sun
>            Priority: Major
>
> Here is an example to show proposed syntax and backend API(Java's 
> {{CompletableFuture}} or GPars's {{{}Promise{}}}), but I think it's better 
> for Groovy to have its own {{Promise}} to decouple with Java API because 
> async/await as a language feature should be as stable as possible.
> {{async}} will generate the {{Awaitable}} instance such as Groovy {{Promise}} 
> implementing the {{Awaitable}} interface, and {{await}} can wait for any 
> {{Awaitable}} instance to complete and unwrap it for the result. 
> {code:java}
> /**
>  * 1. An async function that simulates a network API call.
>  * The 'async' keyword implies it runs asynchronously without blocking.
>  */
> async fetchUserData(userId) {
>     println "Starting to fetch data for user ${userId}..."
>     
>     // Simulate a 1-second network delay.
>     Thread.sleep(1000) 
>     
>     println "Fetch successful!"
>     // The 'async' function implicitly returns a "CompletableFuture" or 
> "Promise" containing this value.
>     return [userId: userId, name: 'Daniel']
> }
> /**
>  * 2. An async function that uses 'await' to consume the result.
>  */
> async processUserData() {
>     println "Process started, preparing to fetch user data..."
>     
>     try {
>         // 'await' pauses this function until fetchUserData completes
>         // and returns the final result directly.
>         def user = await fetchUserData(1)
>         
>         println "Data received: ${user}"
>         return "Processing complete for ${user.name}."
>         
>     } catch (Exception e) {
>         return "An error occurred: ${e.message}"
>     }
> }
> // --- Execution ---
> println "Script starting..."
> // Kick off the entire asynchronous process.
> def future = processUserData()
> // This line executes immediately, proving the process is non-blocking.
> println "Script continues to run while user data is being fetched in the 
> background..."
> def result = future.get()
> println "Script finished: ${result}"
> {code}
> Use async/await with closure or lambda expression:
> {code}
> // use closure
> def c = async {
>     println "Process started, preparing to fetch user data..."
>     
>     try {
>         // 'await' pauses this function until fetchUserData completes
>         // and returns the final result directly.
>         def user = await fetchUserData(1)
>         
>         println "Data received: ${user}"
>         return "Processing complete for ${user.name}."
>         
>     } catch (Exception e) {
>         return "An error occurred: ${e.message}"
>     }
> }
> def future = c()
> {code}
> {code}
> // use lambda expression
> def c = async () -> {
>     println "Process started, preparing to fetch user data..."
>     
>     try {
>         // 'await' pauses this function until fetchUserData completes
>         // and returns the final result directly.
>         def user = await fetchUserData(1)
>         
>         println "Data received: ${user}"
>         return "Processing complete for ${user.name}."
>         
>     } catch (Exception e) {
>         return "An error occurred: ${e.message}"
>     }
> }
> def future = c()
>  {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to