-
Notifications
You must be signed in to change notification settings - Fork 65
TaskManagerConfig
To config TaskManager's default behavior. TaskManager Config is optional.
用于配置TaskManager的一些默认配置。若不配置,TM将采用内部默认设置。
TaskManager.config()
.setDefaultTimeOut(3000)
.setLogTracker(host ? TMTracker.get() : null)
.enableMemoryCleanUp(true)
.enableObjectReuse(true)
.enableFullLog(false)
.setWaitTimeCollectThreshold(500)
.initTaskManager(application);
public TaskManagerConfig setDefaultTimeOut(int timeOut)
To set default blocking time for API "TM.needTaskSync".
用于设置任务的默认等待时间。
public TaskManagerConfig setLogTracker(ITracker tracker)
ITracker is an interface for TM debug system. If a tracker has been set , you can enable debug crash checking , critical log out put etc...
ITracker 是TM的调试接口。设置Tracker后,可以开启debug crash 以暴露验严重务逻辑问题,输出关键日志等等。
public TaskManagerConfig enableObjectReuse(boolean enable) new feature added in 1.3.5.
If object reuse is enabled , some of TM's object will be resued.
public boolean isFullLogEnabled(boolean enable)
If enabled, full log will be output to ITracker.
public TaskManagerConfig setWaitTimeCollectThreshold(int time)
If any statement is waiting for a task to finish for more than threshold time, the waiting stack trace will be printed to ITracker.
当等待任务完成的时间超出设定的阈值,代码阻塞位置的堆栈信息将会被打印到ITracker。
public TaskManagerConfig setLowTaskPriorityTaskMaxWaitTime(int timeInms)
TM has supported dynamic task priority. It a task has been waiting for too long , the task priority will be changed, so that it can gain cpu time.
TM 支持了动态优先级,任务的优先级将随着等待时间的增加而升高。从而保证低优先级的任务也能得到CPU时间。
🌟 New API 1.3.7
public TaskManagerConfig setThreadPoolStrategy(int strategy) Added in 1.3.7.
By default, new thread pool is used for TM tasks to provide a bettter performance. You may call setThreadPoolStrategy(ITaskManagerConfig.STRATEGY_POOL_EXECUTOR) to switch back to the former thread pool.
默认使用新的线程池。新线程池的可靠性正在验证中。可通过此方法切换到旧的线程池。
public void initTaskManager(Application application)
Config TaskManager.