CppCon 2016 - Herb Sutter “Leak-Freedom in C++... By Default.”-
https://goo.gl/2TNgQI
--
Double linked list:
How?
Not detectable from 1 object, or subgroup.
Idea:
heap for deffered_ptr is isolated.
Each module could have one isolated heap.
github.com/hsutter/gcpp
https://goo.gl/2TNgQI
--
- Ensure an object will be destroyed once it is no longer needed.
- Correct by construction!
template<typename T> using Pimpl = const unique_ptr<T>; unique_ptr<data[]> ptr;
Double linked list:
- a unique_ptr to the next
- a raw ptr to the back
- https://www.justsoftwaresolutions.co.uk/cplusplus/shared-ptr-secret-constructor.html
- Used for passing the leaf of a tree d.s around while keeping the root/tree alive.
- Do not violate layering.
- Don't create ownership cycles across modules by owning 'upward' (violates layering)
- Use weak_ptr to break cycles.
How?
- Don't pass an owner down to 'unknow code' that might store it.
e.g storing a shared_ptr - Simple.
Use weak_ptr inside the call back callable object which point
to outside resource.
- 1 object, 1 owner:
unique_ptr - 1 object , n owners:
shared_ptr - N objects, 1 or n owners:
deffered_ptr
Not detectable from 1 object, or subgroup.
Idea:
heap for deffered_ptr is isolated.
Each module could have one isolated heap.
github.com/hsutter/gcpp
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.