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

AfterFunc with go #24

Open
learnergo opened this issue Dec 19, 2018 · 4 comments
Open

AfterFunc with go #24

learnergo opened this issue Dec 19, 2018 · 4 comments

Comments

@learnergo
Copy link

if smallestDuration > 0 {
		table.cleanupTimer = time.AfterFunc(smallestDuration, func() {
			go table.expirationCheck()
		})
}

AfterFunc creates a new goroute.Is it necessary to use 'go' in 'AfterFunc'

@muesli
Copy link
Owner

muesli commented Dec 19, 2018

I think it's preferred because otherwise cleaning up the table (which can be a costly routine) would block the caller.

@learnergo
Copy link
Author

I think "go" should be here:

if item.lifeSpan > 0 && (expDur == 0 || item.lifeSpan < expDur) {
		go table.expirationCheck()
}

@Nassue
Copy link

Nassue commented Feb 18, 2019

I think "go" should be here:

if item.lifeSpan > 0 && (expDur == 0 || item.lifeSpan < expDur) {
		go table.expirationCheck()
}

it will run more times, not just run once for smallestDuration

@learnergo
Copy link
Author

I think "go" should be here:

if item.lifeSpan > 0 && (expDur == 0 || item.lifeSpan < expDur) {
		go table.expirationCheck()
}

it will run more times, not just run once for smallestDuration

??

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

3 participants