1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Description: Preserves the Files.fileTreeTraverser() method that was removed from the public API in Guava 25.
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: not-needed
--- a/guava/src/com/google/common/util/concurrent/MoreExecutors.java
+++ b/guava/src/com/google/common/util/concurrent/MoreExecutors.java
@@ -297,6 +297,42 @@
.build());
}
+ /**
+ * Creates an executor service that runs each task in the thread that invokes
+ * {@code execute/submit}, as in {@link CallerRunsPolicy}. This applies both to individually
+ * submitted tasks and to collections of tasks submitted via {@code invokeAll} or
+ * {@code invokeAny}. In the latter case, tasks will run serially on the calling thread. Tasks are
+ * run to completion before a {@code Future} is returned to the caller (unless the executor has
+ * been shutdown).
+ *
+ * <p>Although all tasks are immediately executed in the thread that submitted the task, this
+ * {@code ExecutorService} imposes a small locking overhead on each task submission in order to
+ * implement shutdown and termination behavior.
+ *
+ * <p>The implementation deviates from the {@code ExecutorService} specification with regards to
+ * the {@code shutdownNow} method. First, "best-effort" with regards to canceling running tasks is
+ * implemented as "no-effort". No interrupts or other attempts are made to stop threads executing
+ * tasks. Second, the returned list will always be empty, as any submitted task is considered to
+ * have started execution. This applies also to tasks given to {@code invokeAll} or
+ * {@code invokeAny} which are pending serial execution, even the subset of the tasks that have
+ * not yet started execution. It is unclear from the {@code ExecutorService} specification if
+ * these should be included, and it's much easier to implement the interpretation that they not
+ * be. Finally, a call to {@code shutdown} or {@code shutdownNow} may result in concurrent calls
+ * to {@code invokeAll/invokeAny} throwing RejectedExecutionException, although a subset of the
+ * tasks may already have been executed.
+ *
+ * @since 10.0 (<a href="https://github.com/google/guava/wiki/Compatibility">mostly
+ * source-compatible</a> since 3.0)
+ * @deprecated Use {@link #directExecutor()} if you only require an {@link Executor} and
+ * {@link #newDirectExecutorService()} if you need a {@link ListeningExecutorService}. This
+ * method will be removed in Guava 21.0.
+ */
+ @Deprecated
+ @GwtIncompatible
+ public static ListeningExecutorService sameThreadExecutor() {
+ return new DirectExecutorService();
+ }
+
// See newDirectExecutorService javadoc for behavioral notes.
@GwtIncompatible // TODO
private static final class DirectExecutorService extends AbstractListeningExecutorService {
|