-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
问一下,ring.go作用是什么 #109
Comments
https://zh.wikipedia.org/wiki/%E7%92%B0%E5%BD%A2%E7%B7%A9%E8%A1%9D%E5%8D%80 在这里,我想一方面可以复用对象, 另外一方面心跳的一来一回正好和它的两个指针(write 和read)很像. 另外数组的实现比链表对CPU更友好 |
无锁的一个ring 复用数据结构用的; |
@Terry-Mao 关于这个请教一个可能比较业余的问题。这里面的wp和rp都一定能保证原子性么?否则的话为什么就能保证线程安全呢。 另外有看到例如缓冲池的大小设置为5,如果消费能力很差的情况下,客户端连接就会断开,这个是出于什么目的呢? |
能保证原子,取决于CPU 平台,64的话,确实是原子,但是 不一定goroutine 可见,这个是一个问题,可以用atomic来处理,目前相对比较少遇到这种问题(不可见),不过确实不安全 缓冲池,根据业务可以调整; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问一下,ring.go作用是什么
The text was updated successfully, but these errors were encountered: