CameraXExecutors

class CameraXExecutors
kotlin.Any
   ↳ androidx.camera.core.impl.utils.executor.CameraXExecutors

Utility class for generating specific implementations of Executor.

Summary

Public methods

static Executor

Returns a cached executor that runs tasks directly from the calling thread.

static Executor

static Executor

Returns a cached Executor suitable for disk I/O.

static Boolean
isSequentialExecutor(@NonNull executor: Executor)

Returns whether the executor is a sequential executor as returned by newSequentialExecutor(Executor).

static ScheduledExecutorService

Returns a cached ScheduledExecutorService which posts to the main thread.

static ScheduledExecutorService

Returns an executor which posts to the thread's current Looper.

static ScheduledExecutorService
newHandlerExecutor(@NonNull handler: Handler)

Returns an executor which posts to the given Handler.

static Executor
newSequentialExecutor(@NonNull delegate: Executor)

Returns a new executor which will perform all tasks sequentially.

Public methods

directExecutor

@NonNull static fun directExecutor(): Executor

Returns a cached executor that runs tasks directly from the calling thread.

highPriorityExecutor

@NonNull static fun highPriorityExecutor(): Executor
Return
Executor: a cached high priority Executor suitable for lightweight tasks.

ioExecutor

@NonNull static fun ioExecutor(): Executor

Returns a cached Executor suitable for disk I/O.

isSequentialExecutor

static fun isSequentialExecutor(@NonNull executor: Executor): Boolean

Returns whether the executor is a sequential executor as returned by newSequentialExecutor(Executor).

mainThreadExecutor

@NonNull static fun mainThreadExecutor(): ScheduledExecutorService

Returns a cached ScheduledExecutorService which posts to the main thread.

myLooperExecutor

@NonNull static fun myLooperExecutor(): ScheduledExecutorService

Returns an executor which posts to the thread's current Looper.

Return
ScheduledExecutorService: An executor which posts to the thread's current looper.
Exceptions
IllegalStateException if the current thread does not have a looper.

newHandlerExecutor

@NonNull static fun newHandlerExecutor(@NonNull handler: Handler): ScheduledExecutorService

Returns an executor which posts to the given Handler.

Return
ScheduledExecutorService: An executor which posts to the given handler.

newSequentialExecutor

@NonNull static fun newSequentialExecutor(@NonNull delegate: Executor): Executor

Returns a new executor which will perform all tasks sequentially.

The returned executor delegates all tasks to the provided delegate Executor, but will ensure all tasks are run in order and without overlapping. Note this can only be guaranteed for tasks that are submitted via the same sequential executor. Tasks submitted directly to the delegate or to different instances of the sequential executor do not have any ordering guarantees.