I'm working with mutex and when building the code, its throwing an error: 'error: use of deleted function ‘std::mutex::mutex(const std::mutex&)'
I understand why I'm getting this error, referred to this answer: Attempting to reference a deleted function when using a mutex. Now, I don't know how can I actually acquire the mutex stored in the instance being copied. Any general example would help. Thanks!
EDIT
file.h
class A
{
...
std::mutex taskMutex;
bool isExecuting;
...
}
file.cpp
int function1
{
std::unique_lock<std::mutex> lock(taskMutex);
...
( lambda func executing )
isExecuting = true
...
isExecuting = false
}
int function2
{
while(isExecuting);
std::unique_lock<std::mutex> lock(taskMutex);
}