IDM: Implement lock-free smart pointers #16403
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replaces
std::shared_pointer
withstx::atomic_ptr
andstx::shared_ptr
.Notes to programmers:
dynamic_cast
,std::dynamic_pointer_cast
andstd::weak_ptr
on IDM objects, possible replacement is to save the object ID on the base object, then use idm::check/get_unlocked to the destination type via the saved ID which may be null. Null pointer check is how you can tell type mismatch (as dynamic cast) or object destruction (as weak_ptr locking).stx::shared_ptr
does not support constant-evaluated pointer offsetting to parent/child type.idm::check/get_unlocked
can now be used anywhere.idm::find_unlocked
has been removed,idm::withdraw
andidm::remove_verify
now have unlocked overloads withstd::true_type
.Misc fixes:
id_manager::typeinfo
comparison to compare members instead ofmemcmp
which can fail spuriously on padding bytes.id_base
orid_type
defined locally, this allows to make getters such asidm::get_unlocked<lv2_socket, lv2_socket_raw>()
which were broken before. (requires save-states invalidation)stx::shared_ptr
andstx::single_ptr
for non-array types.