You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/07/18 10:01:56 UTC
[groovy] branch master updated: Tweak parallel querying of GINQ
further
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new e7150d6 Tweak parallel querying of GINQ further
e7150d6 is described below
commit e7150d64c9dfb080db666096cc09c3134cc7d558
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jul 18 18:01:53 2021 +0800
Tweak parallel querying of GINQ further
---
.../groovy/ginq/provider/collection/GinqAstWalker.groovy | 5 +----
.../ginq/provider/collection/runtime/QueryableHelper.groovy | 10 ++++------
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/GinqAstWalker.groovy b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/GinqAstWalker.groovy
index bb0739f..819f979 100644
--- a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/GinqAstWalker.groovy
+++ b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/GinqAstWalker.groovy
@@ -214,10 +214,7 @@ class GinqAstWalker implements GinqAstVisitor<Expression>, SyntaxErrorReportable
def resultLambda = lambdaX(block(statementList as Statement[]))
def result = parallelEnabled
- ? callX(
- callX(QUERYABLE_HELPER_TYPE, 'submit', args(resultLambda)),
- "get"
- )
+ ? callX(callX(QUERYABLE_HELPER_TYPE, 'submit', args(resultLambda)), "get")
: callX(resultLambda, "call")
ginqExpressionStack.pop()
diff --git a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableHelper.groovy b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableHelper.groovy
index dab108b..bcf2958 100644
--- a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableHelper.groovy
+++ b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableHelper.groovy
@@ -31,7 +31,6 @@ import java.util.function.Function
import java.util.function.Supplier
import java.util.stream.Collectors
-import static groovy.lang.Tuple.tuple
import static org.apache.groovy.ginq.provider.collection.runtime.Queryable.from
/**
* Helper for {@link Queryable}
@@ -111,9 +110,8 @@ class QueryableHelper {
* Shutdown to release resources
*
* @param mode 0: immediate, 1: abort
- * @return list of tasks that never commenced execution
*/
- static Tuple2<List<Runnable>, List<Runnable>> shutdown(int mode) {
+ static void shutdown(int mode) {
if (0 == mode) {
ThreadPoolHolder.FORKJOIN_POOL.shutdown()
ThreadPoolHolder.THREAD_POOL.shutdown()
@@ -124,15 +122,15 @@ class QueryableHelper {
while (!ThreadPoolHolder.THREAD_POOL.awaitTermination(250, TimeUnit.MILLISECONDS)) {
// do nothing, just wait to terminate
}
- return tuple(Collections.emptyList(), Collections.emptyList())
} else if (1 == mode) {
- return tuple(ThreadPoolHolder.FORKJOIN_POOL.shutdownNow(), ThreadPoolHolder.THREAD_POOL.shutdownNow())
+ ThreadPoolHolder.FORKJOIN_POOL.shutdownNow()
+ ThreadPoolHolder.THREAD_POOL.shutdownNow()
} else {
throw new IllegalArgumentException("Invalid mode: $mode")
}
}
- private static final ThreadLocal<Map<String, Object>> VAR_HOLDER = ThreadLocal.<Map<String, Object>> withInitial(() -> new LinkedHashMap<>())
+ private static final ThreadLocal<Map<String, Object>> VAR_HOLDER = InheritableThreadLocal.<Map<String, Object>> withInitial(() -> new LinkedHashMap<>())
private static final String PARALLEL = "parallel"
private static final String TRUE_STR = "true"