Package sonia.scm.repository.spi
Interface SyncAsyncExecutor
public interface SyncAsyncExecutor
Tasks submitted to this executor will be run synchronously up to a given time, after which they will be queued and
processed asynchronously. After a maximum amount of time consumed by these tasks, they will be skipped. Note that
this only works for short-living tasks.
Get instances of this using a SyncAsyncExecutorProvider.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault SyncAsyncExecutor.ExecutionTypeExecute the given task (either synchronously or asynchronously).default SyncAsyncExecutor.ExecutionTypeExecute the giventask(either synchronously or asynchronously).default SyncAsyncExecutor.ExecutionTypeExecute the giventask(either synchronously or asynchronously).execute(Consumer<SyncAsyncExecutor.ExecutionType> task, Runnable abortionFallback) Execute the giventask(either synchronously or asynchronously).booleanWhen all submitted tasks have been executed synchronously, this will returntrue.
-
Method Details
-
execute
Execute the given task (either synchronously or asynchronously). If this task is skipped due to timeouts, nothing will be done.- Parameters:
task- TheRunnableto be executed.- Returns:
- Either
SyncAsyncExecutor.ExecutionType.SYNCHRONOUSwhen the givenRunnablehas been executed immediately orSyncAsyncExecutor.ExecutionType.ASYNCHRONOUS, when the task was queued to be executed asynchronously in the future.
-
execute
Execute the giventask(either synchronously or asynchronously). If this task is skipped due to timeouts, theabortionFallbackwill be called.- Parameters:
task- TheRunnableto be executed.abortionFallback- This will only be run, when this and all remaining tasks are aborted. This task should only consume a negligible amount of time.- Returns:
- Either
SyncAsyncExecutor.ExecutionType.SYNCHRONOUSwhen the givenRunnablehas been executed immediately orSyncAsyncExecutor.ExecutionType.ASYNCHRONOUS, when the task was queued to be executed asynchronously in the future.
-
execute
Execute the giventask(either synchronously or asynchronously). If this task is skipped due to timeouts, nothing will be done.- Parameters:
task- TheConsumerto be executed. The parameter given to this is eitherSyncAsyncExecutor.ExecutionType.SYNCHRONOUSwhen the givenConsumeris executed immediately orSyncAsyncExecutor.ExecutionType.ASYNCHRONOUS, when the task had been queued and now is executed asynchronously.- Returns:
- Either
SyncAsyncExecutor.ExecutionType.SYNCHRONOUSwhen the givenRunnablehas been executed immediately orSyncAsyncExecutor.ExecutionType.ASYNCHRONOUS, when the task was queued to be executed asynchronously in the future.
-
execute
SyncAsyncExecutor.ExecutionType execute(Consumer<SyncAsyncExecutor.ExecutionType> task, Runnable abortionFallback) Execute the giventask(either synchronously or asynchronously). If this task is skipped due to timeouts, theabortionFallbackwill be called.- Parameters:
task- TheConsumerto be executed. The parameter given to this is eitherSyncAsyncExecutor.ExecutionType.SYNCHRONOUSwhen the givenConsumeris executed immediately orSyncAsyncExecutor.ExecutionType.ASYNCHRONOUS, when the task had been queued and now is executed asynchronously.abortionFallback- This will only be run, when this and all remaining tasks are aborted. This task should only consume a negligible amount of time.- Returns:
- Either
SyncAsyncExecutor.ExecutionType.SYNCHRONOUSwhen the givenRunnablehas been executed immediately orSyncAsyncExecutor.ExecutionType.ASYNCHRONOUS, when the task was queued to be executed asynchronously in the future.
-
hasExecutedAllSynchronously
boolean hasExecutedAllSynchronously()When all submitted tasks have been executed synchronously, this will returntrue. If at least one task has been enqueued to be executed asynchronously, this returnsfalse(even when none of the enqueued tasks have been run, yet).
-