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


Constructor & Destructor Documentation

Database::Mutex::Mutex  ) 
 

Definition at line 248 of file Database.cpp.

References m_mutex.

00249 {
00250 #ifdef _WIN32
00251         m_mutex = ::CreateMutex(NULL, FALSE, NULL);
00252 #else
00253         pthread_mutex_init(&m_mutex, NULL);
00254 #endif
00255 }

Database::Mutex::~Mutex  ) 
 

Definition at line 258 of file Database.cpp.

References m_mutex.

00259 {
00260 #ifdef _WIN32
00261         ::CloseHandle(m_mutex);
00262 #else
00263         pthread_mutex_destroy(&m_mutex);
00264 #endif
00265 }


Member Function Documentation

void Database::Mutex::Lock  ) 
 

Definition at line 268 of file Database.cpp.

References m_mutex.

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

00269 {
00270 #ifdef _WIN32
00271         DWORD d = WaitForSingleObject(m_mutex, INFINITE);
00272         // %! check 'd' for result
00273 #else
00274         pthread_mutex_lock(&m_mutex);
00275 #endif
00276 }

void Database::Mutex::Unlock  ) 
 

Definition at line 279 of file Database.cpp.

References m_mutex.

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

00280 {
00281 #ifdef _WIN32
00282         ::ReleaseMutex(m_mutex);
00283 #else
00284         pthread_mutex_unlock(&m_mutex);
00285 #endif
00286 }


Member Data Documentation

pthread_mutex_t Database::Mutex::m_mutex [private]
 

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