ch3 sharing data between threads
3.1 problems with sharing data between threads 3.1.1 the definition race condition which is problematic 3.1.2 avoide problematic race conditions 1) protection 2) lock-free 3) transaction 3.2 protecting shared data with mutexes 3.2.1 using mutex std::mutex std::lock_guard 3.2.2 structuring code for protecting shared data mutex and data within same class 3.2.3 race condition inherent in the interfaces the exception free stack: split the top and pop, because if pop return the value, the poped element's copy constructor could throw exception. but the split cause interface problematic race conditions. 1) pass by reference which avoid the copy constructor, 2) only support exception free copy constructor or move consturctor. 3) return the pointer rather than the value which eliminating the copy constructor.(return std::shared_ptr) question is: std::make_shared<T>(?) what is the parameter type??? i think the only thing would be std::make_shared<...