Logo
~Sockets~
~Examples~
~Contact~


Mutex Class Reference
[Threading]

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

#include <Mutex.h>

Inheritance diagram for Mutex:
Collaboration diagram for Mutex:

List of all members.


Public Member Functions

 Mutex ()
 ~Mutex ()
virtual void Lock () const
virtual void Unlock () const

Private Attributes

pthread_mutex_t m_mutex

Detailed Description

Mutex container class, used by Lock.

Definition at line 50 of file Mutex.h.


Constructor & Destructor Documentation

Mutex::Mutex (  ) 

Definition at line 39 of file Mutex.cpp.

References m_mutex.

00040 {
00041 #ifdef _WIN32
00042         m_mutex = ::CreateMutex(NULL, FALSE, NULL);
00043 #else
00044         pthread_mutex_init(&m_mutex, NULL);
00045 #endif
00046 }

Mutex::~Mutex (  ) 

Definition at line 49 of file Mutex.cpp.

References m_mutex.

00050 {
00051 #ifdef _WIN32
00052         ::CloseHandle(m_mutex);
00053 #else
00054         pthread_mutex_destroy(&m_mutex);
00055 #endif
00056 }


Member Function Documentation

void Mutex::Lock (  )  const [virtual]

Implements IMutex.

Definition at line 59 of file Mutex.cpp.

References m_mutex.

00060 {
00061 #ifdef _WIN32
00062         DWORD d = WaitForSingleObject(m_mutex, INFINITE);
00064 #else
00065         pthread_mutex_lock(&m_mutex);
00066 #endif
00067 }

void Mutex::Unlock (  )  const [virtual]

Implements IMutex.

Definition at line 70 of file Mutex.cpp.

References m_mutex.

00071 {
00072 #ifdef _WIN32
00073         ::ReleaseMutex(m_mutex);
00074 #else
00075         pthread_mutex_unlock(&m_mutex);
00076 #endif
00077 }


Member Data Documentation

pthread_mutex_t Mutex::m_mutex [mutable, private]

Definition at line 63 of file Mutex.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) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4