Hello i am writing thread safe wrapper for std::string
class ThreadSafeString
{
public:
ThreadSafeString(std::string&& str) noexcept
{
std::scoped_lock lock(mutexString);
buffer = std::move(str);
}
private:
std::string buffer;
std::mutex mutexString;
};
constructor is marked with warning:
warning C26111: Caller failing to release lock <lock> before calling function <func>.
- what is caller and what is calling function? i dont call any function with same mutex in ctor.
- is my wrapper thread safe? what is better way do thread safe string if i need copy/move ctor/operator=()
question from:
https://stackoverflow.com/questions/65859214/c-thread-safe-string-wrapper 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…