Understanding what const & mutable mean in the context of multiple threads

In this recipe, we will learn how to deal with objects that are labeled const, but contain std::mutex that must be used to ensure thread synchronization. This recipe is important because it is useful to store std::mutex as a private member of a class, but, as soon as you do this, passing an instance of this object as a constant reference (that is, const &) will result in a compiler error. In this recipe, we will demonstrate why this occurs and how to overcome it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset