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

queue的加锁 #2

Open
RoarkShrugged opened this issue Apr 28, 2023 · 1 comment
Open

queue的加锁 #2

RoarkShrugged opened this issue Apr 28, 2023 · 1 comment

Comments

@RoarkShrugged
Copy link

queue的front()和back()方法没有加锁,感觉有可能在别的线程做pop后缩容的时候存在某个时刻q.data[q.begin]访问了一个非法地址

@Elec4d0
Copy link

Elec4d0 commented May 27, 2024

queue的front()和back()方法没有加锁,感觉有可能在别的线程做pop后缩容的时候存在某个时刻q.data[q.begin]访问了一个非法地址

数据结构 也分 线程安全/线程不安全, 一般来说都是同步单线程方法,不加锁的数据结构能够保证性能。

有线程安全的需求可以自己实现相对应的 数据结构

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

2 participants