Difference between revisions of "Advanced C++ Programming Tutorial 6"
From Chilipedia
(→Homework) |
(→Video Timestamp Index) |
||
Line 22: | Line 22: | ||
== Video Timestamp Index == | == Video Timestamp Index == | ||
* [https://youtu.be/omw6x5Dz0BM Tutorial 6.1] | * [https://youtu.be/omw6x5Dz0BM Tutorial 6.1] | ||
+ | * [https://youtu.be/sv6xVi9fH24 Tutorial 6.2] | ||
== Homework == | == Homework == |
Latest revision as of 23:06, 9 November 2019
Share your resources in grand style with shared_ptr
.
Contents
Topics
Part 1
- Review of
unique_ptr
-
shared_ptr
usage scenarios -
use_count
- How to pass/receive resources when
shared_ptr
is involved - Comparing
shared_ptr
s - Conversion from
unique_ptr
toshared_ptr
- Custom deleter for
shared_ptr
Part 2
-
weak_ptr
andlock
- The control block
- Monolithic
make_shared
control block optimization - Race condition and synchronization
- Resource destruction with monolithic control block
-
static_pointer_cast
dynamic_pointer_cast
reinterpret_pointer_cast
const_pointer_cast
-
enable_shared_from_this
Video Timestamp Index
Homework
Part 1
Identify targets in the Memefighter codebase from Intermediate c++ for resource sharing, implement the sharing with std::shared_ptr
, and consider/discuss potential downsides to the resource sharing for each instance of resource sharing. Solution can be found here.
Part 2
Make a simple announcing class, and then use allocate_shared
in conjunction with LocalAlloc
from Win32 to create an instance of that class that is managed by a shared_ptr
with a monolithic control block.