android优化项目管理,GitHub - cpfei927/TaskManager: TaskManager项目是爱奇艺Android团队在做启动优化过程中沉淀的一套任务调度管理库。支持关系依赖,...

Task manager is an Android task management tool. It is capable of handling complex task work flow. It's low-coupling, flexible & stable. It supports relation-based tasks. All tasks will be executed in a well-managed order. It can submit tasks with complex relations such as “Or Dependency” or “And Dependency”. Meanwhile, parallel tasks and serial tasks are also supported.

Supported Features

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.

1. Task dispatcher:

Dispatch task to UI thread or background thread

Dispatch task to run on background thread in FIFO order (behaves like background thread Handler ).

Submit a group of tasks, to run in parallell. (ParallellTask)

To run a task periodically. (TickTask)

Run task while idle. (Task.enableIdleRun)

task_dispatcher.png

2. Event & Data Dispatcher:

a0494806f723fd4109cfa5d39a155c1b.png

3. Advantages:

a) Change serial tasks into parallel tasks by adding task dependencies, so that we can run several tasks in the same time.

493aee85fa1f985028d5d14017f3f6cb.png

b) Task execute guarantee: Call “TM.needTaskSync” before your business running. In order to make sure your tasks prerequisites are proper loaded.

e9163c958129d85e985ffa13ef5ed662.png

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.

Getting Started

add dependencies in your "build.gradle" file

dependencies {

implementation 'com.iqiyi.taskmanager:taskmanager:1.3.7'

}

Developer Guide

TaskAnalyze

TaskAnalyze: Please refer to Task Analyze(任务分析) function in Lens.

TaskRecode: See iqiyi/Lens DataDump Function to check TM task status; You can find running tasks ,finished tasks & task bloking time on DataDump panel.

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);

}

License

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值