Class InlineExecutorService
- java.lang.Object
-
- org.robolectric.android.util.concurrent.InlineExecutorService
-
- All Implemented Interfaces:
Executor
,ExecutorService
@Beta public class InlineExecutorService extends Object implements ExecutorService
Executor service that executes posted tasks as soon as they are posted. Intended to be a replacement forRoboExecutorService
when usingLooperMode.Mode.PAUSED
. UnlikeRoboExecutorService
, will execute tasks on a background thread. This is useful to test Android code that enforces it runs off the main thread. Also consider usingMoreExecutors.directExecutor()
, if your code under test can handle being called from main thread. Also seePausedExecutorService
if you need control over when posted tasks are executed. NOTE: Beta API, subject to change.
-
-
Constructor Summary
Constructors Constructor Description InlineExecutorService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(long l, TimeUnit timeUnit)
void
execute(Runnable command)
<T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>> tasks)
<T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
<T> T
invokeAny(Collection<? extends Callable<T>> tasks)
<T> T
invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
boolean
isShutdown()
boolean
isTerminated()
void
shutdown()
List<Runnable>
shutdownNow()
Future<?>
submit(Runnable task)
<T> Future<T>
submit(Runnable task, T result)
<T> Future<T>
submit(Callable<T> task)
-
-
-
Method Detail
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
public List<Runnable> shutdownNow()
- Specified by:
shutdownNow
in interfaceExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException
- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-
submit
@NonNull public <T> Future<T> submit(@NonNull Callable<T> task)
- Specified by:
submit
in interfaceExecutorService
-
submit
@NonNull public <T> Future<T> submit(@NonNull Runnable task, T result)
- Specified by:
submit
in interfaceExecutorService
-
submit
@NonNull public Future<?> submit(@NonNull Runnable task)
- Specified by:
submit
in interfaceExecutorService
-
invokeAll
@NonNull public <T> List<Future<T>> invokeAll(@NonNull Collection<? extends Callable<T>> tasks) throws InterruptedException
- Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAll
@NonNull public <T> List<Future<T>> invokeAll(@NonNull Collection<? extends Callable<T>> tasks, long timeout, @NonNull TimeUnit unit) throws InterruptedException
- Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAny
@NonNull public <T> T invokeAny(@NonNull Collection<? extends Callable<T>> tasks) throws ExecutionException, InterruptedException
- Specified by:
invokeAny
in interfaceExecutorService
- Throws:
ExecutionException
InterruptedException
-
invokeAny
public <T> T invokeAny(@NonNull Collection<? extends Callable<T>> tasks, long timeout, @NonNull TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException
- Specified by:
invokeAny
in interfaceExecutorService
- Throws:
ExecutionException
InterruptedException
TimeoutException
-
-