Hi,
I suggest you could try to construct a mutex object, by std::mutex, and then call the member function lock() to lock the mutex, call the member function unlock() to unlock it. You could also try to use lock_guard Class.
And then you could use the condition_variable class to wait for an event when you have a mutex of type unique_lock<mutex>. You only need to call wait and notify_one.
Best Regards,
Jeanine
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.