IdlingThreadPoolExecutor
public
class
IdlingThreadPoolExecutor
extends ThreadPoolExecutor
implements
IdlingResource
java.lang.Object | |||
↳ | java.util.concurrent.AbstractExecutorService | ||
↳ | java.util.concurrent.ThreadPoolExecutor | ||
↳ | android.support.test.espresso.idling.concurrent.IdlingThreadPoolExecutor |
A ThreadPoolExecutor
that can be registered as an IdlingResource
with Espresso.
Overrides parent methods to monitor threads starting, and finishing execution. Uses CountingIdlingResource
to track number of active tasks.
This API is currently in beta.
Summary
Public constructors | |
---|---|
IdlingThreadPoolExecutor(String resourceName, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
Creates a new |
Public methods | |
---|---|
void
|
execute(Runnable command)
|
String
|
getName()
Returns the name of the resources (used for logging and idempotency of registration). |
boolean
|
isIdleNow()
Returns |
void
|
registerIdleTransitionCallback(IdlingResource.ResourceCallback callback)
Registers the given |
Protected methods | |
---|---|
void
|
afterExecute(Runnable r, Throwable t)
|
void
|
terminated()
|
Inherited methods | |
---|---|
From
class
java.util.concurrent.ThreadPoolExecutor
| |
From
class
java.util.concurrent.AbstractExecutorService
| |
From
class
java.lang.Object
| |
From
interface
java.util.concurrent.ExecutorService
| |
From
interface
android.support.test.espresso.IdlingResource
| |
From
interface
java.util.concurrent.Executor
|
Public constructors
IdlingThreadPoolExecutor
IdlingThreadPoolExecutor (String resourceName, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
Creates a new IdlingThreadPoolExecutor
with the given initial parameters and default
rejected execution handler.
Parameters | |
---|---|
resourceName |
String : the name of the executor (used for logging and idempotency of
registration). |
corePoolSize |
int : the number of threads to keep in the pool, even if they are idle, unless
allowCoreThreadTimeOut is set. |
maximumPoolSize |
int : the maximum number of threads to allow in the pool. |
keepAliveTime |
long : when the number of threads is greater than the core, this is the maximum
time that excess idle threads will wait for new tasks before terminating. |
unit |
TimeUnit : the time unit for the keepAliveTime argument. |
workQueue |
BlockingQueue : the queue to use for holding tasks before they are executed. This queue will
hold only the Runnable tasks submitted by the execute method. |
threadFactory |
ThreadFactory : the factory to use when the executor creates a new thread.
|
Public methods
getName
String getName ()
Returns the name of the resources (used for logging and idempotency of registration).
Returns | |
---|---|
String |
isIdleNow
boolean isIdleNow ()
Returns true
if resource is currently idle. Espresso will always call this
method from the main thread, therefore it should be non-blocking and return immediately.
Returns | |
---|---|
boolean |
registerIdleTransitionCallback
void registerIdleTransitionCallback (IdlingResource.ResourceCallback callback)
Registers the given IdlingResource.ResourceCallback
with the resource. Espresso will call this method:
- with its implementation of
IdlingResource.ResourceCallback
so it can be notified asynchronously that your resource is idle - from the main thread, but you are free to execute the callback's onTransitionToIdle from any thread
- once (when it is initially given a reference to your IdlingResource)
You only need to call this upon transition from busy to idle - if the resource is already idle when the method is called invoking the call back is optional and has no significant impact.
Parameters | |
---|---|
callback |
IdlingResource.ResourceCallback |
Protected methods
terminated
void terminated ()