Mutex.cpp
author sl
Mon, 17 Mar 2014 12:38:39 +0100
changeset 3 d5f6b2119a13
permissions -rw-r--r--
Fixing init result issue.
sl@0
     1
//------------------------------------------------------------------------------
sl@0
     2
#include "Mutex.h"
sl@0
     3
//------------------------------------------------------------------------------
sl@0
     4
Mutex::Mutex()
sl@0
     5
{
sl@0
     6
  m_hMutex = CreateMutex(NULL, FALSE, NULL);
sl@0
     7
}
sl@0
     8
//------------------------------------------------------------------------------
sl@0
     9
Mutex::~Mutex()
sl@0
    10
{
sl@0
    11
  if (m_hMutex)
sl@0
    12
    CloseHandle(m_hMutex);
sl@0
    13
}
sl@0
    14
//------------------------------------------------------------------------------
sl@0
    15
void Mutex::Request() const
sl@0
    16
{
sl@0
    17
  WaitForSingleObject(m_hMutex, INFINITE);
sl@0
    18
}
sl@0
    19
//------------------------------------------------------------------------------
sl@0
    20
void Mutex::Release() const
sl@0
    21
{
sl@0
    22
  ReleaseMutex(m_hMutex);
sl@0
    23
}
sl@0
    24
//------------------------------------------------------------------------------