一种支持依赖关系、任务兜底策略的任务调度管理工具。API灵活易用,稳定可靠。轻松提交主线程任务、异步任务。支持周期性任务,顺序执行任务,并行任务等。
TM.postAsync(Runnable); // run on background thread
TM.postAsyncDelay(Runnable);
TM.postUI(Runnable); // run on UI thread
TM.postUIDelay(Runnable, int delay);
TM.postSerial(Runnable , String groupName);//tasks with same group name , runs in FIFO order.
TM.cancelTaskByToken(Object);// cancel tasks with same token.
a) Change serial tasks into parallel tasks by adding task dependencies, so that we can run several tasks in the same time.
b) Task execute guarantee: Call “TM.needTaskSync” before your business running. In order to make sure your tasks prerequisites are proper loaded.
c) Task recursive dependency testing: In debug mode , task recursive test will be executed in order to avoid some wrong relationship been set to tasks.
add dependencies in your "build.gradle" file
dependencies {
implementation 'com.iqiyi.taskmanager:taskmanager:1.3.7'
}
LensUtil.setDumper(MyDumpFactory.class);
@Override
public ILogDumper create() {
return AnnotationLogDumper.create(this)
// Dump.class:注解类;
//LensApp.getInstance(): 查询注解的单例对象
//StaticDump.class:查询带注静态方法的类
.add(Dump.class, LensApp.getInstance(), StaticDump.class)
//"TM" : 别名
//TMDump.class:注解类;
// TaskManager.getInstance():查询注解的单例对象
.add("TM",TMDump.class, TaskManager.getInstance(), TaskRecorder.class);
}
TaskManager is Apache v2.0 Licensed.