Add a concurrent structure: butil/containers/sync_map which inspired by sync.map in go#625
Closed
Aleda wants to merge 1 commit intoapache:masterfrom
Closed
Add a concurrent structure: butil/containers/sync_map which inspired by sync.map in go#625Aleda wants to merge 1 commit intoapache:masterfrom
Aleda wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
|
这个好像 brpc 里并没有用到? |
Contributor
|
有多线程环境下的性能测试结果么? |
Author
|
是的,这个并不涉及brpc本身,只是作为一个单独数据结构提到butils作为借鉴与后续出现类似场景的使用。 |
chenzhangyi
requested changes
Feb 28, 2019
|
|
||
| namespace butil { | ||
|
|
||
| class LinkNode { |
Member
There was a problem hiding this comment.
为什么需要重新实现linked list? container下面的不能满足需求?
| LinkNode* _tail; | ||
| }; | ||
|
|
||
| class sync_list { |
Member
There was a problem hiding this comment.
这里采用class name 使用 snake name的理由是什么?
| _head.store(node, std::memory_order_release); | ||
| } | ||
|
|
||
| bool cas_head(LinkNode* expected, LinkNode* node) noexcept { |
Member
There was a problem hiding this comment.
lock free list使用cas是存在经典的ABA问题, 有gc的语言由于全局gc的存在不受到影响,这里确认这样是没问题的?
|
|
||
| template <class Key, class Value, typename Hasher> | ||
| sync_map<Key, Value, Hasher>::~sync_map() { | ||
| butil::AutoLock lock(_lock); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.