Comments (6)
initInterceptor只会调用一次,这个是由整个SDK的初始化流程控制的,SDK的初始化是有锁的。
from arouter.
这段代码里面是由线程池执行的,对里面的TreeMap的读取和对ArrayList的写入不会造成问题吗?
from arouter.
逻辑上不会,拦截器的初始化确实是在线程池中异步的,但是第一次路由调用的时候,如果拦截器没有初始化完的话,路由请求会等待拦截器初始化结束, checkInterceptorsInitStatus() ,不会同时读写的。
from arouter.
我的意思是
// Cache interceptor
private static Map<Integer, Class<? extends IInterceptor>> interceptorsIndex = new TreeMap<>();
private static List<IInterceptor> interceptors = new ArrayList<>();
是否需要换成线程安全的Map和List
异步里面如果一个线程在初始化最后一个拦截器 而另一个线程不进入for循序就去执行下面的
interceptorHasInit = true;
这样的话checkInterceptorsInitStatus()是否就失效了呢
from arouter.
initInterceptor只会调用一次,这个是由整个SDK的初始化流程控制的,SDK的初始化是有锁的。
如果不考虑上下文的话,单看这段代码是有线程安全风险的,但是首先这个方法不会被调用多次,他只会被调用一次,是通过ARouter.init()里面的锁来控制的,这就保证了interceptorHasInit不会被多次修改,其次这个List的读取是一定在写入完成之后,是由interceptorHasInit这个标志位来控制的,以上,这里应该是没有问题的。
from arouter.
恩 好的 谢谢你的解答 ~
from arouter.
Related Issues (20)
- 通过三方插件对ARouter提供KSP注解处理器支持, 帮助大家移除KAPT、提升kotlin项目编译速度
- It's outrageous, why is it strongly related to the calling order of the code:
- Fork了一个版本,适配了AGP8.0,可直接远程引用,链接见内
- 希望能适配 APG 7.3+ HOT 5
- 初始化耗时-BlockCanaryContext检测
- AS 火烈鸟 构建性能提示 HOT 2
- The following annotation processors are not incremental: jetified-arouter-compiler-1.1.4.jar (com.alibaba:arouter-compiler:1.1.4). Make sure all annotation processors are incremental to improve your build speed. :module_device:compileYF_PRODebugJavaWithJavac spend 78ms
- 安卓Android 7.1.1报错:
- Android7.1.1报错:Attempt to read from field 'java.lang.String com.android.server.am.ActivityRecord.packageName' on a null object reference,具体信息如下:
- 同时使用arouter 和 hilt报错 HOT 7
- 基于 KSP 和 AGP 8 的重构版本 HOT 3
- 自定义类型值不传崩溃
- It will caused NullPointException if we implement the interface of 'PretreatmentService' with Kotlin language
- ⚠️⚠️⚠️新写了一个Android路由库,Gradle8.0+自动注册,同样的API,更多的功能.
- 以后再用阿里的开源库我就是狗 HOT 3
- gradle 8.0构建项目报错API 'android.registerTransform' is removed. HOT 3
- 被通付盾安全监测出一个中危漏洞,贵司有计划修复一下么? HOT 1
- R8混淆报错了-dontwarn javax.lang.model.element.**
- Android 14 java.lang.NoClassDefFoundError
- com.alibaba.android.arouter.launcher._ARouter.startActivity(_ARouter.java:444)报错
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arouter.