-
Notifications
You must be signed in to change notification settings - Fork 4k
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
support SharedMutex. #1975
support SharedMutex. #1975
Conversation
related: #1031 |
CI is failed |
3a2ceb4
to
8f5506d
Compare
@wwbmmm I have fixed the build, the CI failure seems unrelated to this patch, please help check it. |
@guodongxiaren Please help to see this CI failure, the error is so strange. |
8f5506d
to
080a018
Compare
@wwbmmm I have merged master, the workflows need approval |
080a018
to
49b01ea
Compare
|
||
static constexpr int32_t max_readers = 1 << 30; | ||
Mutex _w; | ||
uint32_t* _writer_butex; |
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.
改成butil::atomic<uint32_t>*,保证操作的内存序
static constexpr int32_t max_readers = 1 << 30; | ||
Mutex _w; | ||
uint32_t* _writer_butex; | ||
uint32_t* _reader_butex; |
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.
同上
建议补充单测 |
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.
需要补充单测和注释,特别是牵涉到atomic的部分。 要注释里面说清楚为什么这种实现在所有组合下都是线程安全的。
Closed this as completed in #2752. |
support SharedMutex that is compatible with c++17 std::shared_mutex. This patch uses existing class Mutex, and is migrated from golang, see https://github.com/golang/go/blob/master/src/sync/rwmutex.go