-
Notifications
You must be signed in to change notification settings - Fork 162
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
syncx: SegmentKeysLock #224
Comments
是需要类似这样的实现吗?其实就是预申请很多把锁,对加解锁进行封装,以及通过hash的方式来取用锁。
|
是的 |
好,已提交pr: |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
仅限中文
使用场景
在很多时候,我们需要对 key 进行加锁。但是如果一个 key 一个锁,又很难管理,大概率是需要借助 sync.Map 来实现。
但是我们有一种更加简单的办法来达成类似的效果。
也就是将 key 进行哈希,获得对应的 lock 之后加锁。
行业分析
可行方案
可以在初始化的时候直接初始化好全部的 locks,这样后续不管是加锁还是解锁,直接操作下标,都是只读的,所以不会有并发问题。
其它
你使用的是 ekit 哪个版本?
你设置的的 Go 环境?
The text was updated successfully, but these errors were encountered: