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

timewheel/timewheel.go 中的 break 无法终止外层for循环 #15

Open
withz opened this issue Jul 30, 2024 · 0 comments
Open

timewheel/timewheel.go 中的 break 无法终止外层for循环 #15

withz opened this issue Jul 30, 2024 · 0 comments

Comments

@withz
Copy link

withz commented Jul 30, 2024

timewheel/timewheel.go

下面代码中的 break 似乎只能在 select 中起作用,不能终止外层的 for 循环。是不是应该给外层 for 循环打上 LOOP 标签,使用 break LOOP 来终止外层循环

func (t *TimeWheel) run() {
	for {
		select {
		case _ = <-t.ticker.C:
			t.runTask()
		case task := <-t.addTaskCh:
			t.addTask(task, true)
		case id := <-t.removeTaskCh:
			t.delTask(id)
		case _ = <-t.closeCh:
			t.ticker.Stop()
			break
		}
	}
}
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

1 participant