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

x/time: is not working on huge goroutine #39547

Closed
Petelin opened this issue Jun 12, 2020 · 1 comment
Closed

x/time: is not working on huge goroutine #39547

Petelin opened this issue Jun 12, 2020 · 1 comment

Comments

@Petelin
Copy link

Petelin commented Jun 12, 2020

i write such test code

func main() {
	l := rate.NewLimiter(100, 1)

	var runCounts = new(atomic.Int64)

	go func() {
		for {
			go func() {
				t := time.Now()
				ok := l.AllowN(t, 1)
				if ok {
					runCounts.Inc()
				}
			}()
		}
	}()

	<-time.After(time.Second * 5)
	fmt.Println(runCounts.Load())
	return
}

i expect result is around 501, but actually it may be a very loard number like 12694.

is there any miss understanding?

@gopherbot gopherbot added this to the Unreleased milestone Jun 12, 2020
@toothrot
Copy link
Contributor

For asking questions about learning the language, see one of our forums: https://golang.org/wiki/Questions. We only use this issue tracker for tracking bugs. People in the forums can explain what is happening here.

@golang golang locked and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants