-
Notifications
You must be signed in to change notification settings - Fork 841
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
RingBuffer: 100% cpu usage #150
Comments
$go env |
$go version |
Im seeing the same. (Go 1.8) package main
import (
"github.com/Workiva/go-datastructures/queue"
)
func main() {
rb := queue.NewRingBuffer(5)
rb.Get()
} 100% cpu usage for above |
100% CPU any news for this? |
I need do this:
|
another patch use chan notification, run better now
|
Ideally we should add a new method which returns as soon as we find out the buffer is empty, and returns a boolean to allow users to decide what they want to do in this case (busy waiting, sleep, or something else). This is we do in For now users can workaround this issue by replacing |
$uname -a
Linux Lee-Ubuntu 4.4.0-28-generic #47-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$cat /etc/issue
Linux Lee-Ubuntu 4.4.0-28-generic #47-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$go env
Linux Lee-Ubuntu 4.4.0-28-generic #47-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Test code:
"github.com/Workiva/go-datastructures/queue"
go func() {
defer wg.Done()
for {
time.Sleep(3 * time.Second)
q.Offer("hello world")
}
}()
go func() {
defer wg.Done()
for {
str, _ := q.Get()
fmt.Println(str)
}
}()
wg.Wait()
The text was updated successfully, but these errors were encountered: