shubhamvishu commented on code in PR #12183:
URL: https://github.com/apache/lucene/pull/12183#discussion_r1325031509


##########
lucene/core/src/java/org/apache/lucene/search/TaskExecutor.java:
##########
@@ -64,4 +68,57 @@ final <T> List<T> invokeAll(Collection<RunnableFuture<T>> 
tasks) throws IOExcept
     }
     return results;
   }
+
+  /**
+   * Execute all the tasks provided as an argument concurrently only if it is 
a {@link
+   * ThreadPoolExecutor} and the current thread invoking this is not a {@link 
ThreadPoolExecutor}
+   * thread, else run all the tasks sequentially, wait for them to complete 
and return the obtained
+   * results.
+   *
+   * @param tasks the tasks to execute
+   * @return a list containing the results from the tasks execution
+   * @param <T> the return type of the task execution
+   */
+  public final <T> List<T> 
invokeAllWithThreadPoolExecutor(Collection<RunnableFuture<T>> tasks)
+      throws IOException {
+    boolean executeOnCallerThread;
+    long frames;
+    try {
+      frames =
+          StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE)

Review Comment:
   @uschindler Indeed!....I discovered this when I tried the other 
options(which seems to require no/less privileges?). But this led me to have a 
fail-safe approach to not throw exception in this case and fallback to running 
these tasks sequentially. Let me know if it makes sense?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to