-
Notifications
You must be signed in to change notification settings - Fork 277
Small shared n-way pointer #4654
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
Small shared n-way pointer #4654
Conversation
a45b763
to
c3720e9
Compare
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: c3720e9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/111756419
src/util/small_shared_n_way_ptr.h
Outdated
return *this; | ||
} | ||
|
||
Num use_count() const |
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.
Could we actually name this get_use_count
to avoid the final underscore in use_count_
? It would also seem a lot more consistent, because we have increment_use_count
and decrement_use_count
.
src/util/small_shared_n_way_ptr.h
Outdated
|
||
void increment_use_count() | ||
{ | ||
PRECONDITION((use_count_ & use_count_mask) < use_count_mask); |
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.
Nit pick: use get_use_count()
src/util/small_shared_n_way_ptr.h
Outdated
|
||
void decrement_use_count() | ||
{ | ||
PRECONDITION((use_count_ & use_count_mask) > 0); |
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.
Nit pick: use get_use_count()
src/util/small_shared_n_way_ptr.h
Outdated
{ | ||
PRECONDITION((use_count_ & use_count_mask) < use_count_mask); | ||
|
||
use_count_++; |
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.
Nit pick: use pre-increment rather than having the compiler figure this out.
src/util/small_shared_n_way_ptr.h
Outdated
{ | ||
PRECONDITION((use_count_ & use_count_mask) > 0); | ||
|
||
use_count_--; |
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.
Nit pick: use pre-decrement rather than making the compiler figure this out.
c3720e9
to
e2528e3
Compare
This replaces small_shared_two_way_ptrt with small_shared_n_way_ptrt. The new shared pointer type allows more than two types for the managed objects. This can be useful e.g. for implementing graph data structures with sharing where there are more than two different node types.
e2528e3
to
922adf0
Compare
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 922adf0).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/111896232
This replaces
small_shared_two_way_ptrt
withsmall_shared_n_way_ptrt
. The new shared pointer type allows more than two types for the managed objects. This can be useful e.g. for implementing graph data structures with sharing where there are more than two different node types.This is in preparation for a sharing map improvement where a further node type will be introduced for leaf nodes that are not at the bottom of the tree (which will be possible once the variable-height tree PR #4641 has been merged).