Package com.couchbase.lite.internal.exec
Interface ExecutionService
-
- All Known Implementing Classes:
AbstractExecutionService
,AndroidExecutionService
public interface ExecutionService
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ExecutionService.Cancellable
A Cancellable represents a delayed task that is cancellable.static interface
ExecutionService.CloseableExecutor
Like an ExecutorService, but simpler.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cancelDelayedTask(ExecutionService.Cancellable future)
Best effort cancellation of a delayed task.ExecutionService.CloseableExecutor
getConcurrentExecutor()
Get the concurrent execution service.Executor
getDefaultExecutor()
Get the main executor.ExecutionService.CloseableExecutor
getSerialExecutor()
Get a new, serial executor.ExecutionService.Cancellable
postDelayedOnExecutor(long delayMs, Executor executor, Runnable task)
Run the passed task on the passed executor, after a delay
-
-
-
Method Detail
-
getDefaultExecutor
@NonNull Executor getDefaultExecutor()
Get the main executor. It is guaranteed to be a single thread. Suitable for any task that doesn't take a long time to complete.- Returns:
- the main executor.
-
getSerialExecutor
@NonNull ExecutionService.CloseableExecutor getSerialExecutor()
Get a new, serial executor. Not a single thread but does guarantee serial execution. Suitable for heavyweight that must be executed in order. That is most of them.- Returns:
- a serial executor.
-
getConcurrentExecutor
@NonNull ExecutionService.CloseableExecutor getConcurrentExecutor()
Get the concurrent execution service. Executes tasks on a multi-threaded Executor. Suitable for heavyweight tasks. There is no guarantee for order of execution.- Returns:
- the background thread-pool executor.
-
postDelayedOnExecutor
@NonNull ExecutionService.Cancellable postDelayedOnExecutor(long delayMs, @NonNull Executor executor, @NonNull Runnable task)
Run the passed task on the passed executor, after a delay- Parameters:
delayMs
- delay before posting the task. There may be additional queue delays in the executor.executor
- a executor on which to execute the task.task
- the task to be executed.- Returns:
- a cancellable task
-
cancelDelayedTask
void cancelDelayedTask(@NonNull ExecutionService.Cancellable future)
Best effort cancellation of a delayed task.- Parameters:
future
- object returned by a previous call to postDelayedOnExecutor.
-
-