Replacement of Class Referenced with std::shared_ptr#541
Conversation
(intern calls need to be adjusted)
ref_ptr now acts like a normal smart pointer and is able to hold a reference by using ref_ptr(T& obj)
comment previously commented test for now, search fix later
|
I am not sure why exactly the ubuntu tests are failing, I cannot reproduce the issue and the log does not give a clear answer as to why the error occurs. |
|
Turns out the issue was caused by the |
The following changes are included: - Optional python (now not required to build crpropa) - Limit in secondary samples in tests to limit necessary memory - Some performance adjustments
|
I discussed the modification of I also ran the test with the 1000 max sample limit 1000 times on our cluster to check if I encounter any fails (the test takes about 1ms) , and so far I did not encounter any. |
Hi,
as discussed in the workshop I want to replace the
Referencedclass withstd::shared_ptr.Referencedwas used to reference count in crpropa versions that required C++ standards lower then C++11, however since C++11 thestd::shared_ptrtemplate class was introduced as a better manageable smart pointer provided by C++.To properly use
std::shared_ptrinstead ofReferencedsome other general modifications needed to be done:ref_ptrmight be converted into a raw pointer and then back into aref_ptrwhich would cause the reference count of thestd::shared_ptrto not be synced anymore and therefore might cause the unintended deletion of pointers.ref_ptrfor theprocessfunctionsThe following will work the same as before:
ref_ptr<Candidate> c = new Candidate();std::shared_ptrwhen converted toref_ptrin function call)Some other changes include:
Contribute.md)AssocVecbystd::unordered_mapClockbystd::chrono::high_resolution_clockI marked this PR as Draft for now (currently CRPropa3.2.1) so it is clear that we only intend to add this after we release CRPropa3.3.0 . Furthermore, with the upcoming #535 and the heavy nuclei PR this PR would only delay the 3.3 release more, so considering that and the required changes to this PR when the mentioned PRs are merged I think a draft PR is the best choice.