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 09:28:41 UTC
[groovy] branch master updated: Tweak `shutdown` of GINQ
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 e3eddaf Tweak `shutdown` of GINQ
e3eddaf is described below
commit e3eddaf6f9f793010f7d2caf47c65e4cb7ae84f7
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jul 18 17:28:34 2021 +0800
Tweak `shutdown` of GINQ
---
.../ginq/provider/collection/runtime/QueryableHelper.groovy | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
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 dcebcc3..dab108b 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,6 +31,7 @@ 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}
@@ -112,15 +113,20 @@ class QueryableHelper {
* @param mode 0: immediate, 1: abort
* @return list of tasks that never commenced execution
*/
- static List<Runnable> shutdown(int mode) {
+ static Tuple2<List<Runnable>, List<Runnable>> shutdown(int mode) {
if (0 == mode) {
+ ThreadPoolHolder.FORKJOIN_POOL.shutdown()
ThreadPoolHolder.THREAD_POOL.shutdown()
+
+ while (!ThreadPoolHolder.FORKJOIN_POOL.awaitTermination(250, TimeUnit.MILLISECONDS)) {
+ // do nothing, just wait to terminate
+ }
while (!ThreadPoolHolder.THREAD_POOL.awaitTermination(250, TimeUnit.MILLISECONDS)) {
// do nothing, just wait to terminate
}
- return Collections.emptyList()
+ return tuple(Collections.emptyList(), Collections.emptyList())
} else if (1 == mode) {
- return ThreadPoolHolder.THREAD_POOL.shutdownNow()
+ return tuple(ThreadPoolHolder.FORKJOIN_POOL.shutdownNow(), ThreadPoolHolder.THREAD_POOL.shutdownNow())
} else {
throw new IllegalArgumentException("Invalid mode: $mode")
}