Scope.supplyWithNewScope(com.github.phantomthief.util.ThrowableSupplier<T, X>) 或者 Scope.runWithNewScope(com.github.phantomthief.util.ThrowableRunnable<X>)
手工使用beginScope和endScope的场景只有在:
上面两个方法当需要抛出多个正交异常时会造成不必要的try/catch代码
开始scope和结束scope不在一个代码块中
close() 关闭追踪Scope 各个方法读写数据
可以通过 Scope.supplyWithExistScope(com.github.phantomthief.scope.Scope, com.github.phantomthief.util.ThrowableSupplier<T, X>) 或者 Scope.runWithExistScope(com.github.phantomthief.scope.Scope, com.github.phantomthief.util.ThrowableRunnable<X>) 绑定已经存在的scope
举个栗子:Scope 级联,并且支持单次调用独立设置超时的异步重试封装Copyright © 2019. All rights reserved.