-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Use sync.Pool for reclaiming unused posting.List #223
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
Conversation
…rivate, and pass it back from GetOrCreate, which is safer.
| } | ||
| if lp := getFromMap(gotomicKey); lp != nil { | ||
| return lp, lp.decr | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
| l.init(key, pstore) | ||
| return l, l.decr | ||
|
|
||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
|
Review status: 0 of 12 files reviewed at latest revision, 2 unresolved discussions. posting/lists.go, line 300 at r1 (raw file):
|
|
Review status: 0 of 12 files reviewed at latest revision, 10 unresolved discussions, some commit checks broke. posting/list.go, line 85 at r2 (raw file):
Nit: Missing empty line posting/list.go, line 90 at r2 (raw file):
x.Assertf(val < 0, "List reference ....: %v", val) posting/lists.go, line 277 at r2 (raw file):
nit: (if it's not there already) posting/lists.go, line 294 at r2 (raw file):
spelling: "its" posting/lists.go, line 296 at r2 (raw file):
Maybe add comment: Increment counter due to reference from lhmap? posting/lists.go, line 301 at r2 (raw file):
Maybe add comment: decr is to undo the incr in newList call? posting/lists.go, line 307 at r2 (raw file):
posting/lists.go, line 326 at r2 (raw file):
Maybe add comment at Delete or here saying that Delete returns a reference to the deleted value, so it doesn't call l.decr? Comments from Reviewable |
|
Review status: 0 of 12 files reviewed at latest revision, 10 unresolved discussions, some commit checks broke. posting/list.go, line 85 at r2 (raw file):
|
We have to do this via reference counting because multiple goroutines might be holding the same pointer.
This change is