Chapter 7

Resource Management

Images

Cippi maintains the garden.

First, what is a resource? A resource is something that you have to manage. That means you have to acquire and release it because resources are limited, or you have to protect it. You can have only a limited amount of memory, sockets, processes, or threads; only one process can write a shared file or one thread can write a shared variable at one point in time. If you don’t follow the protocol, many issues are possible.

If you think about resource management, it all boils down to one critical point: ownership. What I like in particular about modern C++ is that we can directly express ...

Get C++ Core Guidelines Explained: Best Practices for Modern C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.