Forums  +  C++ and Sockets  +  C++ and SQL: MySQL, sqlite, ODBC  +  Miscellaneous Projects
Logo
~Database~
~ C++ ~
~Contact~

Database::Mutex Class Reference

Mutex container class, used by Lock. More...

#include <Database.h>

Collaboration diagram for Database::Mutex:

Collaboration graph
List of all members.

Public Member Functions

 Mutex ()
 ~Mutex ()
void Lock ()
void Unlock ()

Private Attributes

pthread_mutex_t m_mutex

Detailed Description

Mutex container class, used by Lock.

Definition at line 66 of file Database.h.


Constructor & Destructor Documentation

Database::Mutex::Mutex (  ) 

Definition at line 230 of file Database.cpp.

References m_mutex.

00231 {
00232 #ifdef _WIN32
00233         m_mutex = ::CreateMutex(NULL, FALSE, NULL);
00234 #else
00235         pthread_mutex_init(&m_mutex, NULL);
00236 #endif
00237 }

Database::Mutex::~Mutex (  ) 

Definition at line 240 of file Database.cpp.

References m_mutex.

00241 {
00242 #ifdef _WIN32
00243         ::CloseHandle(m_mutex);
00244 #else
00245         pthread_mutex_destroy(&m_mutex);
00246 #endif
00247 }


Member Function Documentation

void Database::Mutex::Lock (  ) 

Definition at line 250 of file Database.cpp.

References m_mutex.

Referenced by Database::Lock::Lock().

00251 {
00252 #ifdef _WIN32
00253         DWORD d = WaitForSingleObject(m_mutex, INFINITE);
00254         // %! check 'd' for result
00255 #else
00256         pthread_mutex_lock(&m_mutex);
00257 #endif
00258 }

void Database::Mutex::Unlock (  ) 

Definition at line 261 of file Database.cpp.

References m_mutex.

Referenced by Database::Lock::~Lock().

00262 {
00263 #ifdef _WIN32
00264         ::ReleaseMutex(m_mutex);
00265 #else
00266         pthread_mutex_unlock(&m_mutex);
00267 #endif
00268 }


Member Data Documentation

pthread_mutex_t Database::Mutex::m_mutex [private]

Definition at line 76 of file Database.h.

Referenced by Lock(), Mutex(), Unlock(), and ~Mutex().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström