IdlingScheduledThreadPoolExecutor


class IdlingScheduledThreadPoolExecutor : ScheduledThreadPoolExecutor, IdlingResource


A ScheduledThreadPoolExecutor that can be registered as an IdlingResource with Espresso.

Overrides parent methods to monitor threads starting, and finishing execution. Uses to track number of active tasks.

Summary

Public constructors

IdlingScheduledThreadPoolExecutor(
    resourceName: String!,
    corePoolSize: Int,
    threadFactory: ThreadFactory!
)

Creates a new IdlingScheduledThreadPoolExecutor with the given initial parameters.

IdlingScheduledThreadPoolExecutor(
    resourceName: String!,
    corePoolSize: Int,
    threadFactory: ThreadFactory!,
    debugCounting: Boolean
)

Creates a new IdlingScheduledThreadPoolExecutor with the given initial parameters.

Public functions

String!

Returns the name of the resources (used for logging and idempotency of registration).

Boolean

Returns true if resource is currently idle.

Unit

Registers the given ResourceCallback with the resource.

ScheduledFuture<V!>!
<V> schedule(callable: Callable<V!>!, delay: Long, unit: TimeUnit!)
ScheduledFuture<Any!>!
schedule(command: Runnable!, delay: Long, unit: TimeUnit!)

Protected functions

Unit
Unit
Unit

Inherited functions

From java.util.concurrent.AbstractExecutorService
(Mutable)List<Future<T!>!>!
<T> invokeAll(tasks: (Mutable)Collection<Callable<T!>!>!)
T!
<T> invokeAny(tasks: (Mutable)Collection<Callable<T!>!>!)
RunnableFuture<T!>!
<T> newTaskFor(runnable: Runnable!, value: T!)
From java.util.concurrent.ScheduledThreadPoolExecutor
From java.util.concurrent.ThreadPoolExecutor

Public constructors

IdlingScheduledThreadPoolExecutor

IdlingScheduledThreadPoolExecutor(
    resourceName: String!,
    corePoolSize: Int,
    threadFactory: ThreadFactory!
)

Creates a new IdlingScheduledThreadPoolExecutor with the given initial parameters.

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.

threadFactory: ThreadFactory!

the factory to use when the executor creates a new thread.

IdlingScheduledThreadPoolExecutor

IdlingScheduledThreadPoolExecutor(
    resourceName: String!,
    corePoolSize: Int,
    threadFactory: ThreadFactory!,
    debugCounting: Boolean
)

Creates a new IdlingScheduledThreadPoolExecutor with the given initial parameters.

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.

threadFactory: ThreadFactory!

the factory to use when the executor creates a new thread.

debugCounting: Boolean

if true increment &decrement calls will print trace information to logs.

Public functions

getName

fun getName(): String!

Returns the name of the resources (used for logging and idempotency of registration).

isIdleNow

fun isIdleNow(): Boolean

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.

registerIdleTransitionCallback

fun registerIdleTransitionCallback(
    callback: IdlingResource.ResourceCallback!
): Unit

Registers the given ResourceCallback with the resource. Espresso will call this method:

  • with its implementation of 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.

schedule

fun <V> schedule(callable: Callable<V!>!, delay: Long, unit: TimeUnit!): ScheduledFuture<V!>!

schedule

fun schedule(command: Runnable!, delay: Long, unit: TimeUnit!): ScheduledFuture<Any!>!

Protected functions

afterExecute

protected fun afterExecute(r: Runnable!, t: Throwable!): Unit

beforeExecute

protected fun beforeExecute(t: Thread!, r: Runnable!): Unit

terminated

protected fun terminated(): Unit