Public Member Functions | Public Attributes | List of all members
QMutexPrivate Class Reference

#include <qmutex_p.h>

Public Member Functions

 QMutexPrivate ()
 
 ~QMutexPrivate ()
 
void wait ()
 
void wakeUp ()
 

Public Attributes

QAtomicInt contenders
 
volatile bool wakeup
 
pthread_mutex_t mutex
 
pthread_cond_t cond
 

Detailed Description

Definition at line 68 of file qmutex_p.h.

Constructor & Destructor Documentation

QMutexPrivate::QMutexPrivate ( )

Definition at line 58 of file qmutex_unix.cpp.

59  : contenders(0), wakeup(FALSE)
60 {
61  report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
62  report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
63 }
static void report_error(int code, const char *where, const char *what)
Definition: qmutex_unix.cpp:51
const bool FALSE
Definition: qglobal.h:370
pthread_cond_t cond
Definition: qmutex_p.h:82
QAtomicInt contenders
Definition: qmutex_p.h:77
pthread_mutex_t mutex
Definition: qmutex_p.h:81
volatile bool wakeup
Definition: qmutex_p.h:80
QMutexPrivate::~QMutexPrivate ( )

Definition at line 65 of file qmutex_unix.cpp.

66 {
67  report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
68  report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
69 }
static void report_error(int code, const char *where, const char *what)
Definition: qmutex_unix.cpp:51
pthread_cond_t cond
Definition: qmutex_p.h:82
pthread_mutex_t mutex
Definition: qmutex_p.h:81

Member Function Documentation

void QMutexPrivate::wait ( )

Definition at line 71 of file qmutex_unix.cpp.

72 {
73  report_error(pthread_mutex_lock(&mutex), "QMutex::lock", "mutex lock");
74  int errorCode = 0;
75  while (!wakeup)
76  {
77  errorCode = pthread_cond_wait(&cond, &mutex);
78  if (errorCode)
79  {
80  report_error(errorCode, "QMutex::lock()", "cv wait");
81  }
82  }
83  wakeup = FALSE;
84  report_error(pthread_mutex_unlock(&mutex), "QMutex::lock", "mutex unlock");
85 }
static void report_error(int code, const char *where, const char *what)
Definition: qmutex_unix.cpp:51
const bool FALSE
Definition: qglobal.h:370
pthread_cond_t cond
Definition: qmutex_p.h:82
pthread_mutex_t mutex
Definition: qmutex_p.h:81
volatile bool wakeup
Definition: qmutex_p.h:80
void QMutexPrivate::wakeUp ( )

Definition at line 87 of file qmutex_unix.cpp.

88 {
89  report_error(pthread_mutex_lock(&mutex), "QMutex::unlock", "mutex lock");
90  wakeup = TRUE;
91  report_error(pthread_cond_signal(&cond), "QMutex::unlock", "cv signal");
92  report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock");
93 }
static void report_error(int code, const char *where, const char *what)
Definition: qmutex_unix.cpp:51
pthread_cond_t cond
Definition: qmutex_p.h:82
pthread_mutex_t mutex
Definition: qmutex_p.h:81
volatile bool wakeup
Definition: qmutex_p.h:80
const bool TRUE
Definition: qglobal.h:371

Member Data Documentation

pthread_cond_t QMutexPrivate::cond

Definition at line 82 of file qmutex_p.h.

QAtomicInt QMutexPrivate::contenders

Definition at line 77 of file qmutex_p.h.

pthread_mutex_t QMutexPrivate::mutex

Definition at line 81 of file qmutex_p.h.

volatile bool QMutexPrivate::wakeup

Definition at line 80 of file qmutex_p.h.


The documentation for this class was generated from the following files: