Skip to content

Commit

Permalink
Merge pull request #1292 from warunalakshitha/java21
Browse files Browse the repository at this point in the history
Add yieldAndRun API changes
  • Loading branch information
warunalakshitha authored Oct 11, 2024
2 parents 656404f + 535e9ab commit 3e70033
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.caching=true
group=io.ballerina.stdlib
version=1.6.2-SNAPSHOT
ballerinaLangVersion=2201.10.0-20240926-231800-8a5a4343
ballerinaLangVersion=2201.10.0-20241011-161100-51978649
puppycrawlCheckstyleVersion=10.12.0
testngVersion=7.6.1
slf4jVersion=1.7.30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ public static BString readln(Environment env, Object result) {
if (result != null) {
printStream.print(result);
}
env.markAsync();
CompletableFuture<BString> future = new CompletableFuture<>();
Thread.startVirtualThread(() -> future.complete(StringUtils.fromString(sc.nextLine())));
try {
return future.get();
} catch (Throwable e) {
throw ErrorCreator.createError(e);
}
return env.yieldAndRun(() -> {
CompletableFuture<BString> future = new CompletableFuture<>();
Thread.startVirtualThread(() -> future.complete(StringUtils.fromString(sc.nextLine())));
try {
return future.get();
} catch (Throwable e) {
throw ErrorCreator.createError(e);
}
});
}
}

0 comments on commit 3e70033

Please sign in to comment.