66import android .os .HandlerThread ;
77import android .os .Looper ;
88import android .os .Process ;
9+ import android .util .Log ;
910
1011import java .util .concurrent .BlockingQueue ;
1112import java .util .concurrent .ExecutionException ;
@@ -35,7 +36,7 @@ public class TaskScheduler {
3536 private ExecutorService mTimeOutExecutor ;
3637 private Handler mIOHandler ;
3738 private SafeSchedulerHandler mMainHandler = new SafeSchedulerHandler (Looper .getMainLooper ());
38-
39+ private ILog mILog ;
3940
4041 private static final int CPU_COUNT = Runtime .getRuntime ().availableProcessors ();
4142 private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1 ;
@@ -72,6 +73,25 @@ private TaskScheduler() {
7273
7374 }
7475
76+ public static void addLogImpl (ILog taskLog ) {
77+ if (taskLog != null ) {
78+ getInstance ().mILog = taskLog ;
79+ }else {
80+ getInstance ().mILog = new ILog () {
81+ @ Override
82+ public void info (String info ) {
83+ Log .i (TAG ,info );
84+ }
85+
86+ @ Override
87+ public void error (String error ) {
88+ Log .e (TAG ,error );
89+ }
90+ };
91+ }
92+
93+ }
94+
7595 public static ExecutorService executorService () {
7696 return getInstance ().mParallelExecutor ;
7797 }
@@ -136,6 +156,7 @@ public static void stopScheduleTask(final SchedulerTask schedulerTask) {
136156 *执行一个后台任务,无回调
137157 * **/
138158 public static void execute (Runnable task ) {
159+ getInstance ().mILog .info ("execute Runnable" +task .toString ());
139160 getInstance ().mParallelExecutor .execute (task );
140161 }
141162
@@ -144,6 +165,7 @@ public static void execute(Runnable task) {
144165 * @see #execute(Runnable)
145166 **/
146167 public static <R > void execute (Task <R > task ) {
168+ getInstance ().mILog .info ("execute task" +task .toString ());
147169 getInstance ().mParallelExecutor .execute (task );
148170 }
149171
0 commit comments