-
public class TaskQueueClass manages priority and dependencies based execution of background tasks.
Queue will reject adding same task in the same time. By default only tasks of the same object or tasks with the same type and ID are considered to be equal.
You can control that behaviour by providing different id and type parameters in Task constructor. See appropriate constructor Task For example of that check com.appsflyer.internal.components.queue.tasks.UpdateRemoteControlTask
-
-
Field Summary
Fields Modifier and Type Field Description private ExecutorserviceExecutorprivate final Set<Task<out Object>>runningTasks
-
Constructor Summary
Constructors Constructor Description TaskQueue(ExecutorService mainExecutor)
-
Method Summary
Modifier and Type Method Description voidsetServiceExecutor(Executor serviceExecutor)Can be used to make all reordering, task add/drop operations synchronous for unit tests Set<Task<out Object>>getRunningTasks()voidaddTask(Task<out Object> task)voidregisterListener(QueueStatusListener listener)voidunRegisterListener(QueueStatusListener listener)booleanshouldRetryInSession(Task<out Object> task)Check if this task should be retried in the current session List<Task<out Object>>getAllPendingTasks()Returns set of tasks which are going to be run in future (actually pending + failed to retry)Result will be returned sorted in the same order it's currently in the Queue -
-
Constructor Detail
-
TaskQueue
TaskQueue(ExecutorService mainExecutor)
-
-
Method Detail
-
setServiceExecutor
void setServiceExecutor(Executor serviceExecutor)
Can be used to make all reordering, task add/drop operations synchronous for unit tests
-
getRunningTasks
Set<Task<out Object>> getRunningTasks()
-
registerListener
void registerListener(QueueStatusListener listener)
-
unRegisterListener
void unRegisterListener(QueueStatusListener listener)
-
shouldRetryInSession
boolean shouldRetryInSession(Task<out Object> task)
Check if this task should be retried in the current session
- Parameters:
task- to verify retry state
-
getAllPendingTasks
List<Task<out Object>> getAllPendingTasks()
Returns set of tasks which are going to be run in future (actually pending + failed to retry)Result will be returned sorted in the same order it's currently in the Queue
-
-
-
-