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

When delay is less than tick, Ticker runs only once #25

Closed
fufuok opened this issue Oct 25, 2021 · 0 comments · May be fixed by #26
Closed

When delay is less than tick, Ticker runs only once #25

fufuok opened this issue Oct 25, 2021 · 0 comments · May be fixed by #26

Comments

@fufuok
Copy link

fufuok commented Oct 25, 2021

new test

func TestTickerSecondLess(t *testing.T) {
	tw, err := NewTimeWheel(10*time.Millisecond, 10000)
	assert.Nil(t, err)

	tw.Start()
	defer tw.Stop()

	var (
		timeout = time.After(1100 * time.Millisecond)
		ticker  = tw.NewTicker(9 * time.Millisecond)
		incr    int
	)

	for run := true; run; {
		select {
		case <-timeout:
			run = false

		case <-ticker.C:
			incr++
		}
	}

	assert.Greater(t, incr, 100)
}

**go test **

go test -v -run=TestTickerSecondLess
=== RUN   TestTickerSecondLess
    timer_test.go:235: 
                Error Trace:    timer_test.go:235
                Error:          "1" is not greater than "100"
                Test:           TestTickerSecondLess
--- FAIL: TestTickerSecondLess (1.10s)
FAIL
exit status 1
FAIL    github.com/rfyiamcool/go-timewheel      1.107s
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

Successfully merging a pull request may close this issue.

2 participants