jeudi 31 mai 2018

Same mutex in multiple function calling each other

I have two functions

void myclass::func()
{
     std::shared_lock<std::mutex>(m_mutex);
     func1();
}

void myclass::func2()
{
     std::shared_lock<std::mutex>(m_mutex);
}

is it right way to using mutex ? or it will cause any problem ? I have lots of function which are doing reading/writing but they are also calling in each other frequently. how should I implement this scenario ?

I am using c++11 for mutex.

Aucun commentaire:

Enregistrer un commentaire