Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿啄debugIT
transmittable-thread-local
提交
c3c03e4d
T
transmittable-thread-local
项目概览
阿啄debugIT
/
transmittable-thread-local
与 Fork 源项目一致
从无法访问的项目Fork
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
transmittable-thread-local
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c3c03e4d
编写于
3月 18, 2020
作者:
oldratlee
🔥
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doTryFinallyForMethod support void return type CtMethod
上级
2a7667a2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
6 deletion
+12
-6
README.md
README.md
+2
-2
src/main/java/com/alibaba/ttl/threadpool/agent/internal/transformlet/impl/TtlForkJoinTransformlet.java
...t/internal/transformlet/impl/TtlForkJoinTransformlet.java
+3
-3
src/main/java/com/alibaba/ttl/threadpool/agent/internal/transformlet/impl/Utils.java
...tl/threadpool/agent/internal/transformlet/impl/Utils.java
+7
-1
未找到文件。
README.md
浏览文件 @
c3c03e4d
...
...
@@ -82,9 +82,9 @@
相比
[
`InheritableThreadLocal`
](
https://docs.oracle.com/javase/10/docs/api/java/lang/InheritableThreadLocal.html
)
,添加了
1.
`
protected`
方法
`copy`
1.
`
copy`
方法
用于定制
**任务提交给线程池时**
的
`ThreadLocal`
值传递到
**任务执行时**
的拷贝行为,缺省传递的是引用。
1.
`protected`
方法
`beforeExecute`
/
`afterExecute`
1.
`protected`
的
`beforeExecute`
/
`afterExecute`
方法
执行任务(
`Runnable`
/
`Callable`
)的前/后的生命周期回调,缺省是空操作。
具体使用方式见下面的说明。
...
...
src/main/java/com/alibaba/ttl/threadpool/agent/internal/transformlet/impl/TtlForkJoinTransformlet.java
浏览文件 @
c3c03e4d
...
...
@@ -57,16 +57,16 @@ public class TtlForkJoinTransformlet implements JavassistTransformlet {
logger
.
info
(
"add new field "
+
capturedFieldName
+
" to class "
+
className
);
final
CtMethod
doExecMethod
=
clazz
.
getDeclaredMethod
(
"doExec"
,
new
CtClass
[
0
]);
final
String
doExec_renamed_method_
re
name
=
renamedMethodNameByTtl
(
doExecMethod
);
final
String
doExec_renamed_method_name
=
renamedMethodNameByTtl
(
doExecMethod
);
final
String
beforeCode
=
"if (this instanceof "
+
TtlEnhanced
.
class
.
getName
()
+
") {\n"
+
// if the class is already TTL enhanced(eg: com.alibaba.ttl.TtlRecursiveTask)
" return "
+
doExec_renamed_method_
rename
+
"($$);\n"
+
// return directly/do nothing
" return "
+
doExec_renamed_method_
name
+
"($$);\n"
+
// return directly/do nothing
"}\n"
+
"Object backup = com.alibaba.ttl.TransmittableThreadLocal.Transmitter.replay("
+
capturedFieldName
+
");"
;
final
String
finallyCode
=
"com.alibaba.ttl.TransmittableThreadLocal.Transmitter.restore(backup);"
;
doTryFinallyForMethod
(
doExecMethod
,
doExec_renamed_method_
re
name
,
beforeCode
,
finallyCode
);
doTryFinallyForMethod
(
doExecMethod
,
doExec_renamed_method_name
,
beforeCode
,
finallyCode
);
}
private
void
updateConstructorDisableInheritable
(
@NonNull
final
CtClass
clazz
)
throws
NotFoundException
,
CannotCompileException
{
...
...
src/main/java/com/alibaba/ttl/threadpool/agent/internal/transformlet/impl/Utils.java
浏览文件 @
c3c03e4d
...
...
@@ -68,11 +68,17 @@ public class Utils {
&
~
Modifier
.
PROTECTED
/* remove protected */
|
Modifier
.
PRIVATE
/* add private */
);
final
String
returnOp
;
if
(
method
.
getReturnType
()
==
CtClass
.
voidType
)
{
returnOp
=
""
;
}
else
{
returnOp
=
"return "
;
}
// set new method implementation
final
String
code
=
"{\n"
+
beforeCode
+
"\n"
+
"try {\n"
+
"
return "
+
renamedMethodName
+
"($$);\n"
+
"
"
+
returnOp
+
renamedMethodName
+
"($$);\n"
+
"} finally {\n"
+
" "
+
finallyCode
+
"\n"
+
"} }"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录