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 65 of file Database.h.


Constructor & Destructor Documentation

Database::Mutex::Mutex (  ) 

Definition at line 289 of file Database.cpp.

References m_mutex.

00290 {
00291 #ifdef _WIN32
00292         m_mutex = ::CreateMutex(NULL, FALSE, NULL);
00293 #else
00294         pthread_mutex_init(&m_mutex, NULL);
00295 #endif
00296 }

Database::Mutex::~Mutex (  ) 

Definition at line 299 of file Database.cpp.

References m_mutex.

00300 {
00301 #ifdef _WIN32
00302         ::CloseHandle(m_mutex);
00303 #else
00304         pthread_mutex_destroy(&m_mutex);
00305 #endif
00306 }


Member Function Documentation

void Database::Mutex::Lock (  ) 

Definition at line 309 of file Database.cpp.

References m_mutex.

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

00310 {
00311 #ifdef _WIN32
00312         DWORD d = WaitForSingleObject(m_mutex, INFINITE);
00313         // %! check 'd' for result
00314 #else
00315         pthread_mutex_lock(&m_mutex);
00316 #endif
00317 }

void Database::Mutex::Unlock (  ) 

Definition at line 320 of file Database.cpp.

References m_mutex.

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

00321 {
00322 #ifdef _WIN32
00323         ::ReleaseMutex(m_mutex);
00324 #else
00325         pthread_mutex_unlock(&m_mutex);
00326 #endif
00327 }


Member Data Documentation

pthread_mutex_t Database::Mutex::m_mutex [private]

Definition at line 75 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