Answer the question
In order to leave comments, you need to log in
Working with pthread mutex?
Greetings.
There was a question with the work of pthread_mutex_t and pthread_mutex_lock.
There is a multithreaded server class:
class Server
{
private:
pthread_mutex_t _queryQueueMutex;
// ... code ...c
public:
Server();
bool f();
// ... code ...
};
Server::Server()
{
if (pthread_mutex_init(&_queryQueueMutex, NULL))
throw "err";
}
bool Server::f()
{
pthread_mutex_lock(&_queryQueueMutex);
// ... code ...
pthread_mutex_unlock(&_queryQueueMutex);
return false;
}
Server* srv = new Server();
srv->f();
everything works correctly as expected. Server srv();
srv.f();
The thread's execution stops at the pthread_mutex_lock(&_queryQueueMutex) call in the f() function. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question