-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: get rid of unsafe code by arc-swap #234
Conversation
pls |
先前用 unsafe 而不用 RWLock 是因为在单线程下会死锁, |
ArcSwap 提供的是原子替换 Arc 对象的能力,因而可以在不使用锁的前提下提供内部可变性,也就不会有死锁的问题。本文件内的测试是通过了的。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
实际上最好的改法可能还是把改成需要&mut self,这样一来不会存在同时同一毫秒内多个login触发多个请求的问题(因为所有请求实际上被序列化了),二来也不需要通过ArcSwap来处理状态,只是这么改牵动太大。 |
未来有强烈必要则再改,毕竟需要自定义 login 的并不多,需要的同学相信他们也能理解 |
@thynson 在 Send + Sync 的 async 环境下,改为 |
看了下确实不太好改,还有一个是在 |
No description provided.