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 47 of file Mutex.h.


Constructor & Destructor Documentation

Mutex::Mutex (  ) 

Definition at line 37 of file Mutex.cpp.

References m_mutex.

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

Mutex::~Mutex (  ) 

Definition at line 47 of file Mutex.cpp.

References m_mutex.

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


Member Function Documentation

void Mutex::Lock (  )  const [virtual]

Implements IMutex.

Definition at line 57 of file Mutex.cpp.

References m_mutex.

00058 {
00059 #ifdef _WIN32
00060         DWORD d = WaitForSingleObject(m_mutex, INFINITE);
00062 #else
00063         pthread_mutex_lock(&m_mutex);
00064 #endif
00065 }

void Mutex::Unlock (  )  const [virtual]

Implements IMutex.

Definition at line 68 of file Mutex.cpp.

References m_mutex.

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


Member Data Documentation

pthread_mutex_t Mutex::m_mutex [mutable, private]

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