Skip to content
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

关于map flags如何发现并发写问题 #75

Open
Whaleman55 opened this issue Sep 1, 2024 · 0 comments
Open

关于map flags如何发现并发写问题 #75

Whaleman55 opened this issue Sep 1, 2024 · 0 comments

Comments

@Whaleman55
Copy link

问题描述

map赋值时

函数首先会检查 map 的标志位 flags。如果 flags 的写标志位此时被置 1 了,说明有其他协程在执行“写”操作,进而导致程序 panic。这也说明了 map 对协程是不安全的。

但flags本身的线程/协程安全性如何保证呢?如果两个协程恰好同时进行写,flags此时还没有进入写状态,怎么办呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant