Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
Booster
提交
73033b74
B
Booster
项目概览
DiDi
/
Booster
通知
31
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
Booster
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
73033b74
编写于
7月 18, 2020
作者:
J
johnsonlee
提交者:
zhiguoWang
7月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improves thread renaming and optimization
上级
2e4e9b4d
变更
21
展开全部
隐藏空白更改
内联
并排
Showing
21 changed file
with
810 addition
and
95 deletion
+810
-95
booster-android-api/build.gradle
booster-android-api/build.gradle
+2
-2
booster-android-instrument-activity-thread/build.gradle
booster-android-instrument-activity-thread/build.gradle
+2
-2
booster-android-instrument-finalizer-watchdog-daemon/build.gradle
...android-instrument-finalizer-watchdog-daemon/build.gradle
+2
-2
booster-android-instrument-logcat/build.gradle
booster-android-instrument-logcat/build.gradle
+2
-2
booster-android-instrument-media-player/build.gradle
booster-android-instrument-media-player/build.gradle
+2
-2
booster-android-instrument-res-check/build.gradle
booster-android-instrument-res-check/build.gradle
+2
-2
booster-android-instrument-shared-preferences/build.gradle
booster-android-instrument-shared-preferences/build.gradle
+2
-2
booster-android-instrument-thread/build.gradle
booster-android-instrument-thread/build.gradle
+2
-2
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/NamedForkJoinWorkerThreadFactory.java
.../booster/instrument/NamedForkJoinWorkerThreadFactory.java
+34
-0
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/NamedThreadFactory.java
...com/didiglobal/booster/instrument/NamedThreadFactory.java
+22
-1
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowExecutors.java
...va/com/didiglobal/booster/instrument/ShadowExecutors.java
+37
-0
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowHandlerThread.java
...om/didiglobal/booster/instrument/ShadowHandlerThread.java
+25
-1
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowThread.java
.../java/com/didiglobal/booster/instrument/ShadowThread.java
+96
-1
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowThreadPoolExecutor.java
...diglobal/booster/instrument/ShadowThreadPoolExecutor.java
+272
-1
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowTimer.java
...n/java/com/didiglobal/booster/instrument/ShadowTimer.java
+44
-1
booster-android-instrument-toast/build.gradle
booster-android-instrument-toast/build.gradle
+2
-2
booster-android-instrument-webview/build.gradle
booster-android-instrument-webview/build.gradle
+2
-2
booster-android-instrument/build.gradle
booster-android-instrument/build.gradle
+2
-2
booster-transform-spi/src/main/kotlin/com/didiglobal/booster/transform/TransformException.kt
...in/com/didiglobal/booster/transform/TransformException.kt
+15
-0
booster-transform-thread/src/main/kotlin/com/didiglobal/booster/transform/thread/ThreadTransformer.kt
.../didiglobal/booster/transform/thread/ThreadTransformer.kt
+242
-67
build.gradle
build.gradle
+1
-1
未找到文件。
booster-android-api/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
booster-android-instrument-activity-thread/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument-finalizer-watchdog-daemon/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument-logcat/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument-media-player/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument-res-check/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument-shared-preferences/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument-thread/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/NamedForkJoinWorkerThreadFactory.java
0 → 100644
浏览文件 @
73033b74
package
com.didiglobal.booster.instrument
;
import
java.util.concurrent.ForkJoinPool
;
import
java.util.concurrent.ForkJoinWorkerThread
;
import
static
com
.
didiglobal
.
booster
.
instrument
.
ShadowThread
.
makeThreadName
;
/**
* @author johnsonlee
*/
public
class
NamedForkJoinWorkerThreadFactory
implements
ForkJoinPool
.
ForkJoinWorkerThreadFactory
{
private
final
String
name
;
private
final
ForkJoinPool
.
ForkJoinWorkerThreadFactory
factory
;
public
NamedForkJoinWorkerThreadFactory
(
final
ForkJoinPool
.
ForkJoinWorkerThreadFactory
factory
,
final
String
name
)
{
this
.
factory
=
factory
;
this
.
name
=
name
;
}
public
NamedForkJoinWorkerThreadFactory
(
final
String
name
)
{
this
(
null
,
name
);
}
@Override
public
ForkJoinWorkerThread
newThread
(
final
ForkJoinPool
pool
)
{
final
ForkJoinWorkerThread
thread
=
(
null
!=
this
.
factory
)
?
factory
.
newThread
(
pool
)
:
new
ForkJoinWorkerThread
(
pool
)
{};
thread
.
setName
(
makeThreadName
(
thread
.
getName
(),
this
.
name
));
return
thread
;
}
}
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/NamedThreadFactory.java
浏览文件 @
73033b74
...
...
@@ -5,7 +5,28 @@ import java.util.concurrent.atomic.AtomicInteger;
import
static
com
.
didiglobal
.
booster
.
instrument
.
ShadowThread
.
setThreadName
;
class
NamedThreadFactory
implements
ThreadFactory
{
public
class
NamedThreadFactory
implements
ThreadFactory
{
/**
* Used by {@code ThreadTransformer} for thread renaming
*
* @param prefix the prefix of name
* @return an instance of ThreadFactory
*/
public
static
ThreadFactory
newInstance
(
final
String
prefix
)
{
return
new
NamedThreadFactory
(
prefix
);
}
/**
* Used by {@code ThreadTransformer} for thread renaming
*
* @param factory the factory delegate
* @param prefix the prefix of name
* @return an instance of ThreadFactory
*/
public
static
ThreadFactory
newInstance
(
final
ThreadFactory
factory
,
final
String
prefix
)
{
return
new
NamedThreadFactory
(
factory
,
prefix
);
}
private
final
String
name
;
private
final
AtomicInteger
counter
=
new
AtomicInteger
(
1
);
...
...
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowExecutors.java
浏览文件 @
73033b74
...
...
@@ -7,6 +7,7 @@ import java.util.concurrent.Callable;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ForkJoinPool
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ScheduledExecutorService
;
...
...
@@ -107,6 +108,30 @@ public class ShadowExecutors {
// </editor-fold>
// <editor-fold desc="- named work stealing pool">
public
static
ExecutorService
newWorkStealingPool
(
final
String
name
)
{
return
new
ForkJoinPool
(
Runtime
.
getRuntime
().
availableProcessors
(),
new
NamedForkJoinWorkerThreadFactory
(
name
),
null
,
true
);
}
public
static
ExecutorService
newWorkStealingPool
(
final
int
parallelism
,
final
String
name
)
{
return
new
ForkJoinPool
(
parallelism
,
new
NamedForkJoinWorkerThreadFactory
(
name
),
null
,
true
);
}
// </editor-fold>
// <editor-fold desc="- optimized fixed thread pool">
public
static
ExecutorService
newOptimizedFixedThreadPool
(
final
int
nThreads
,
final
String
name
)
{
return
Executors
.
newFixedThreadPool
(
nThreads
,
new
NamedThreadFactory
(
name
));
}
public
static
ExecutorService
newOptimizedFixedThreadPool
(
final
int
nThreads
,
final
ThreadFactory
factory
,
final
String
name
)
{
return
Executors
.
newFixedThreadPool
(
nThreads
,
new
NamedThreadFactory
(
factory
,
name
));
}
// </editor-fold>
// <editor-fold desc="* optimized single thread scheduled executor">
public
static
ScheduledExecutorService
newOptimizedSingleThreadScheduledExecutor
(
final
String
name
)
{
...
...
@@ -175,6 +200,18 @@ public class ShadowExecutors {
//</editor-fold>
// <editor-fold desc="* optimized work stealing pool">
public
static
ExecutorService
newOptimizedWorkStealingPool
(
final
String
name
)
{
return
new
ForkJoinPool
(
Runtime
.
getRuntime
().
availableProcessors
(),
new
NamedForkJoinWorkerThreadFactory
(
name
),
null
,
true
);
}
public
static
ExecutorService
newOptimizedWorkStealingPool
(
final
int
parallelism
,
final
String
name
)
{
return
new
ForkJoinPool
(
parallelism
,
new
NamedForkJoinWorkerThreadFactory
(
name
),
null
,
true
);
}
// </editor-fold>
private
static
class
DelegatedExecutorService
extends
AbstractExecutorService
{
private
final
ExecutorService
executor
;
...
...
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowHandlerThread.java
浏览文件 @
73033b74
...
...
@@ -5,7 +5,10 @@ import android.os.HandlerThread;
import
static
com
.
didiglobal
.
booster
.
instrument
.
ShadowThread
.
makeThreadName
;
import
static
java
.
lang
.
Math
.
min
;
public
class
ShadowHandlerThread
{
/**
* @author johnsonlee
*/
public
class
ShadowHandlerThread
extends
HandlerThread
{
public
static
HandlerThread
newHandlerThread
(
final
String
name
,
final
String
prefix
)
{
return
new
HandlerThread
(
makeThreadName
(
name
,
prefix
));
...
...
@@ -15,4 +18,25 @@ public class ShadowHandlerThread {
return
new
HandlerThread
(
makeThreadName
(
name
,
prefix
),
min
(
android
.
os
.
Process
.
THREAD_PRIORITY_DEFAULT
,
priority
));
}
/**
* Initialize {@code HandlerThread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param name the original name
* @param prefix the prefix of new name
*/
public
ShadowHandlerThread
(
final
String
name
,
final
String
prefix
)
{
super
(
makeThreadName
(
name
,
prefix
));
}
/**
* Initialize {@code HandlerThread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param name the original name
* @param priority the thread priority
* @param prefix the prefix of new name
*/
public
ShadowHandlerThread
(
final
String
name
,
final
int
priority
,
final
String
prefix
)
{
super
(
makeThreadName
(
name
,
prefix
),
priority
);
}
}
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowThread.java
浏览文件 @
73033b74
package
com.didiglobal.booster.instrument
;
public
class
ShadowThread
{
/**
* @author johnsonlee
*/
public
class
ShadowThread
extends
Thread
{
/**
* {@code U+200B}: Zero-Width Space
...
...
@@ -52,4 +55,96 @@ public class ShadowThread {
return
name
==
null
?
prefix
:
(
name
.
startsWith
(
MARK
)
?
name
:
(
prefix
+
"#"
+
name
));
}
/**
* Initialize {@code Thread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param prefix the new name
*/
public
ShadowThread
(
final
String
prefix
)
{
super
(
makeThreadName
(
prefix
));
}
/**
* Initialize {@code Thread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param target the object whose {@code run} method is invoked when this thread is started.
* If {@code null}, this thread's run method is invoked.
* @param prefix the new name
*/
public
ShadowThread
(
final
Runnable
target
,
final
String
prefix
)
{
super
(
target
,
makeThreadName
(
prefix
));
}
/**
* Initialize {@code Thread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param group the thread group
* @param target the object whose {@code run} method is invoked when this thread is started.
* If {@code null}, this thread's run method is invoked.
* @param prefix the new name
*/
public
ShadowThread
(
final
ThreadGroup
group
,
final
Runnable
target
,
final
String
prefix
)
{
super
(
group
,
target
,
makeThreadName
(
prefix
));
}
/**
* Initialize {@code Thread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param name the original name
* @param prefix the prefix of new name
*/
public
ShadowThread
(
final
String
name
,
final
String
prefix
)
{
super
(
makeThreadName
(
name
,
prefix
));
}
/**
* Initialize {@code Thread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param group the thread group
* @param name the original name
* @param prefix the prefix of new name
*/
public
ShadowThread
(
final
ThreadGroup
group
,
final
String
name
,
final
String
prefix
)
{
super
(
group
,
makeThreadName
(
name
,
prefix
));
}
/**
* Initialize {@code Thread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param target the object whose {@code run} method is invoked when this thread is started.
* If {@code null}, this thread's run method is invoked.
* @param name the original name
* @param prefix the prefix of new name
*/
public
ShadowThread
(
final
Runnable
target
,
final
String
name
,
final
String
prefix
)
{
super
(
target
,
makeThreadName
(
name
,
prefix
));
}
/**
* Initialize {@code Thread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param group the thread group
* @param target the object whose {@code run} method is invoked when this thread is started.
* If {@code null}, this thread's run method is invoked.
* @param name the original name
* @param prefix the prefix of new name
*/
public
ShadowThread
(
final
ThreadGroup
group
,
final
Runnable
target
,
final
String
name
,
final
String
prefix
)
{
super
(
group
,
target
,
makeThreadName
(
name
,
prefix
));
}
/**
* Initialize {@code Thread} with new name, this constructor is used by {@code ThreadTransformer} for renaming
*
* @param group the thread group
* @param target the object whose {@code run} method is invoked when this thread is started.
* If {@code null}, this thread's run method is invoked.
* @param name the original name
* @param stackSize the desired stack size for the new thread, or zero to indicate that this parameter is to be ignored.
* @param prefix the prefix of new name
*/
public
ShadowThread
(
final
ThreadGroup
group
,
final
Runnable
target
,
final
String
name
,
final
long
stackSize
,
final
String
prefix
)
{
super
(
group
,
target
,
makeThreadName
(
name
,
prefix
),
stackSize
);
}
}
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowThreadPoolExecutor.java
浏览文件 @
73033b74
...
...
@@ -6,7 +6,10 @@ import java.util.concurrent.ThreadFactory;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
public
class
ShadowThreadPoolExecutor
{
/**
* @author johnsonlee
*/
public
class
ShadowThreadPoolExecutor
extends
ThreadPoolExecutor
{
// <editor-fold desc="- named thread pool executor">
...
...
@@ -84,4 +87,272 @@ public class ShadowThreadPoolExecutor {
// </editor-fold>
/**
* Initialize {@code ThreadPoolExecutor} with new thread name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param corePoolSize the number of threads to keep in the pool, even if they are idle,
* unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the pool
* @param keepAliveTime when the number of threads is greater than the core,
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are executed.
* This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.
* @param prefix the prefix of new thread
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
*/
public
ShadowThreadPoolExecutor
(
final
int
corePoolSize
,
final
int
maximumPoolSize
,
final
long
keepAliveTime
,
final
TimeUnit
unit
,
final
BlockingQueue
<
Runnable
>
workQueue
,
final
String
prefix
)
{
this
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
prefix
,
false
);
}
/**
* Initialize {@code ThreadPoolExecutor} with new thread name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param corePoolSize the number of threads to keep in the pool, even if they are idle,
* unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the pool
* @param keepAliveTime when the number of threads is greater than the core,
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are executed.
* This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.
* @param prefix the prefix of new thread
* @param optimize the value indicates that the thread pool optimization should be applied
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
*/
public
ShadowThreadPoolExecutor
(
final
int
corePoolSize
,
final
int
maximumPoolSize
,
final
long
keepAliveTime
,
final
TimeUnit
unit
,
final
BlockingQueue
<
Runnable
>
workQueue
,
final
String
prefix
,
final
boolean
optimize
)
{
super
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
new
NamedThreadFactory
(
prefix
));
if
(
optimize
)
{
allowCoreThreadTimeOut
(
getKeepAliveTime
(
unit
)
>
0
);
}
}
/**
* Initialize {@code ThreadPoolExecutor} with new thread name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param corePoolSize the number of threads to keep in the pool, even if they are idle,
* unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the pool
* @param keepAliveTime when the number of threads is greater than the core,
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are executed.
* This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.
* @param threadFactory the factory to use when the executor creates a new thread
* @param prefix the prefix of new thread
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
*/
public
ShadowThreadPoolExecutor
(
final
int
corePoolSize
,
final
int
maximumPoolSize
,
final
long
keepAliveTime
,
final
TimeUnit
unit
,
final
BlockingQueue
<
Runnable
>
workQueue
,
final
ThreadFactory
threadFactory
,
final
String
prefix
)
{
this
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
threadFactory
,
prefix
,
false
);
}
/**
* Initialize {@code ThreadPoolExecutor} with new thread name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param corePoolSize the number of threads to keep in the pool, even if they are idle,
* unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the pool
* @param keepAliveTime when the number of threads is greater than the core,
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are executed.
* This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.
* @param threadFactory the factory to use when the executor creates a new thread
* @param prefix the prefix of new thread
* @param optimize the value indicates that the thread pool optimization should be applied
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
*/
public
ShadowThreadPoolExecutor
(
final
int
corePoolSize
,
final
int
maximumPoolSize
,
final
long
keepAliveTime
,
final
TimeUnit
unit
,
final
BlockingQueue
<
Runnable
>
workQueue
,
final
ThreadFactory
threadFactory
,
final
String
prefix
,
final
boolean
optimize
)
{
super
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
new
NamedThreadFactory
(
threadFactory
,
prefix
));
if
(
optimize
)
{
allowCoreThreadTimeOut
(
getKeepAliveTime
(
unit
)
>
0
);
}
}
/**
* Initialize {@code ThreadPoolExecutor} with new thread name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param corePoolSize the number of threads to keep in the pool, even if they are idle,
* unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the pool
* @param keepAliveTime when the number of threads is greater than the core,
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are executed.
* This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.
* @param handler the handler to use when execution is blocked because the thread bounds and queue capacities are reached
* @param prefix the prefix of new thread
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
*/
public
ShadowThreadPoolExecutor
(
final
int
corePoolSize
,
final
int
maximumPoolSize
,
final
long
keepAliveTime
,
final
TimeUnit
unit
,
final
BlockingQueue
<
Runnable
>
workQueue
,
final
RejectedExecutionHandler
handler
,
final
String
prefix
)
{
this
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
handler
,
prefix
,
false
);
}
/**
* Initialize {@code ThreadPoolExecutor} with new thread name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param corePoolSize the number of threads to keep in the pool, even if they are idle,
* unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the pool
* @param keepAliveTime when the number of threads is greater than the core,
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are executed.
* This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.
* @param handler the handler to use when execution is blocked because the thread bounds and queue capacities are reached
* @param prefix the prefix of new thread
* @param optimize the value indicates that the thread pool optimization should be applied
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
*/
public
ShadowThreadPoolExecutor
(
final
int
corePoolSize
,
final
int
maximumPoolSize
,
final
long
keepAliveTime
,
final
TimeUnit
unit
,
final
BlockingQueue
<
Runnable
>
workQueue
,
final
RejectedExecutionHandler
handler
,
final
String
prefix
,
final
boolean
optimize
)
{
super
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
new
NamedThreadFactory
(
prefix
),
handler
);
if
(
optimize
)
{
allowCoreThreadTimeOut
(
getKeepAliveTime
(
unit
)
>
0
);
}
}
/**
* Initialize {@code ThreadPoolExecutor} with new thread name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param corePoolSize the number of threads to keep in the pool, even if they are idle,
* unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the pool
* @param keepAliveTime when the number of threads is greater than the core,
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are executed.
* This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.
* @param threadFactory the factory to use when the executor creates a new thread
* @param handler the handler to use when execution is blocked because the thread bounds and queue capacities are reached
* @param prefix the prefix of new thread
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
*/
public
ShadowThreadPoolExecutor
(
final
int
corePoolSize
,
final
int
maximumPoolSize
,
final
long
keepAliveTime
,
final
TimeUnit
unit
,
final
BlockingQueue
<
Runnable
>
workQueue
,
final
ThreadFactory
threadFactory
,
final
RejectedExecutionHandler
handler
,
final
String
prefix
)
{
this
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
threadFactory
,
handler
,
prefix
,
false
);
}
/**
* Initialize {@code ThreadPoolExecutor} with new thread name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param corePoolSize the number of threads to keep in the pool, even if they are idle,
* unless {@code allowCoreThreadTimeOut} is set
* @param maximumPoolSize the maximum number of threads to allow in the pool
* @param keepAliveTime when the number of threads is greater than the core,
* this is the maximum time that excess idle threads will wait for new tasks before terminating.
* @param unit the time unit for the {@code keepAliveTime} argument
* @param workQueue the queue to use for holding tasks before they are executed.
* This queue will hold only the {@code Runnable} tasks submitted by the {@code execute} method.
* @param threadFactory the factory to use when the executor creates a new thread
* @param handler the handler to use when execution is blocked because the thread bounds and queue capacities are reached
* @param prefix the prefix of new thread
* @param optimize the value indicates that the thread pool optimization should be applied
* @throws IllegalArgumentException if one of the following holds:<br>
* {@code corePoolSize < 0}<br>
* {@code keepAliveTime < 0}<br>
* {@code maximumPoolSize <= 0}<br>
* {@code maximumPoolSize < corePoolSize}
*/
public
ShadowThreadPoolExecutor
(
final
int
corePoolSize
,
final
int
maximumPoolSize
,
final
long
keepAliveTime
,
final
TimeUnit
unit
,
final
BlockingQueue
<
Runnable
>
workQueue
,
final
ThreadFactory
threadFactory
,
final
RejectedExecutionHandler
handler
,
final
String
prefix
,
final
boolean
optimize
)
{
super
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
new
NamedThreadFactory
(
threadFactory
,
prefix
),
handler
);
if
(
optimize
)
{
allowCoreThreadTimeOut
(
getKeepAliveTime
(
unit
)
>
0
);
}
}
}
booster-android-instrument-thread/src/main/java/com/didiglobal/booster/instrument/ShadowTimer.java
浏览文件 @
73033b74
...
...
@@ -4,7 +4,10 @@ import java.util.Timer;
import
static
com
.
didiglobal
.
booster
.
instrument
.
ShadowThread
.
makeThreadName
;
public
class
ShadowTimer
{
/**
* @author johnsonlee
*/
public
class
ShadowTimer
extends
Timer
{
public
static
Timer
newTimer
(
final
String
name
)
{
return
new
Timer
(
name
);
...
...
@@ -22,4 +25,44 @@ public class ShadowTimer {
return
new
Timer
(
makeThreadName
(
name
,
prefix
),
isDaemon
);
}
/**
* Initialize {@code Timer} with new name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param prefix the prefix of new name
*/
public
ShadowTimer
(
final
String
prefix
)
{
super
(
prefix
);
}
/**
* Initialize {@code Timer} with new name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param isDaemon true if the associated thread should run as a daemon
* @param prefix the prefix of new name
*/
public
ShadowTimer
(
final
boolean
isDaemon
,
final
String
prefix
)
{
super
(
prefix
,
isDaemon
);
}
/**
* Initialize {@code Timer} with new name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param name the original name
* @param prefix the prefix of new name
*/
public
ShadowTimer
(
final
String
name
,
final
String
prefix
)
{
super
(
makeThreadName
(
name
,
prefix
));
}
/**
* Initialize {@code Timer} with new name, this constructor is used by {@code ThreadTransformer} for thread renaming
*
* @param name the original name
* @param isDaemon true if the associated thread should run as a daemon
* @param prefix the prefix of new name
*/
public
ShadowTimer
(
final
String
name
,
final
boolean
isDaemon
,
final
String
prefix
)
{
super
(
makeThreadName
(
name
,
prefix
),
isDaemon
);
}
}
booster-android-instrument-toast/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument-webview/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-android-instrument/build.gradle
浏览文件 @
73033b74
sourceCompatibility
=
JavaVersion
.
VERSION_1_
7
targetCompatibility
=
JavaVersion
.
VERSION_1_
7
sourceCompatibility
=
JavaVersion
.
VERSION_1_
8
targetCompatibility
=
JavaVersion
.
VERSION_1_
8
dependencies
{
compileOnly
project
(
':booster-android-api'
)
...
...
booster-transform-spi/src/main/kotlin/com/didiglobal/booster/transform/TransformException.kt
0 → 100644
浏览文件 @
73033b74
package
com.didiglobal.booster.transform
class
TransformException
:
Exception
{
constructor
()
:
super
()
constructor
(
message
:
String
)
:
super
(
message
)
constructor
(
message
:
String
,
cause
:
Throwable
)
:
super
(
message
,
cause
)
constructor
(
cause
:
Throwable
)
:
super
(
cause
)
constructor
(
message
:
String
,
cause
:
Throwable
,
enableSuppression
:
Boolean
,
writableStackTrace
:
Boolean
)
:
super
(
message
,
cause
,
enableSuppression
,
writableStackTrace
)
}
\ No newline at end of file
booster-transform-thread/src/main/kotlin/com/didiglobal/booster/transform/thread/ThreadTransformer.kt
浏览文件 @
73033b74
此差异已折叠。
点击以展开。
build.gradle
浏览文件 @
73033b74
...
...
@@ -32,7 +32,7 @@ allprojects { project ->
apply
plugin:
'de.marcphilipp.nexus-publish'
group
=
'com.didiglobal.booster'
version
=
'2.
2.0
'
version
=
'2.
3.0-SNAPSHOT
'
repositories
{
mavenLocal
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录