-
Notifications
You must be signed in to change notification settings - Fork 853
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
why struct Cache contains pointer to cache? #142
Comments
Line 1115 in 46f4078
|
IMO, Since, the janitor is working in a go routine on cache , c object. It will never be available for garbage collection. Hence, Cache struct is designed to have cache as a field. If Cache struct is garbage collected, stopJanitor is called using the runtime.setFinalizer. runtime.setFinalizer is used to call a function, here stopJanitor, when the first operand , here C, is garbage collected. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it looks like struct
cache
is unnecessary in the code. I notice the comment // If this is confusing, see the comment at the bottom of New(), but i didn't find any explainationThe text was updated successfully, but these errors were encountered: