foobar2000 SDK  2015-08-03
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CMutex

#include <win32_misc.h>

Public Member Functions

 CMutex (const TCHAR *name=NULL)
 
 ~CMutex ()
 
void Acquire (abort_callback &aborter)
 
HANDLE Handle ()
 
void Release ()
 

Static Public Member Functions

static void AcquireByHandle (HANDLE hMutex, abort_callback &aborter)
 

Private Member Functions

 CMutex (const CMutex &)
 
void operator= (const CMutex &)
 

Private Attributes

HANDLE m_hMutex
 

Detailed Description

Definition at line 352 of file win32_misc.h.

Constructor & Destructor Documentation

CMutex::CMutex ( const TCHAR *  name = NULL)

Definition at line 220 of file win32_misc.cpp.

220  {
221  WIN32_OP_CRITICAL( "CreateMutex", m_hMutex = CreateMutex(NULL, FALSE, name) );
222 }
HANDLE m_hMutex
Definition: win32_misc.h:362
CMutex::~CMutex ( )

Definition at line 223 of file win32_misc.cpp.

223  {
224  CloseHandle(m_hMutex);
225 }
HANDLE m_hMutex
Definition: win32_misc.h:362
CMutex::CMutex ( const CMutex )
private

Member Function Documentation

void CMutex::Acquire ( abort_callback aborter)

Definition at line 243 of file win32_misc.cpp.

243  {
244  AcquireByHandle( Handle(), aborter );
245 }
HANDLE Handle()
Definition: win32_misc.h:356
static void AcquireByHandle(HANDLE hMutex, abort_callback &aborter)
Definition: win32_misc.cpp:227
void CMutex::AcquireByHandle ( HANDLE  hMutex,
abort_callback aborter 
)
static

Definition at line 227 of file win32_misc.cpp.

227  {
228  SetLastError(0);
229  HANDLE hWait[2] = {hMutex, aborter.get_abort_event()};
230  switch(WaitForMultipleObjects( 2, hWait, FALSE, INFINITE ) ) {
231  case WAIT_FAILED:
232  WIN32_OP_FAIL_CRITICAL("WaitForSingleObject");
233  case WAIT_OBJECT_0:
234  return;
235  case WAIT_OBJECT_0 + 1:
236  PFC_ASSERT( aborter.is_aborting() );
237  throw exception_aborted();
238  default:
239  uBugCheck();
240  }
241 }
DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds)
Definition: pp-winapi.h:20
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL_CRITICAL(const char *what)
Definition: win32_misc.cpp:58
PFC_NORETURN void SHARED_EXPORT uBugCheck()
HANDLE CMutex::Handle ( )
inline

Definition at line 356 of file win32_misc.h.

356 {return m_hMutex;}
HANDLE m_hMutex
Definition: win32_misc.h:362
void CMutex::operator= ( const CMutex )
private
void CMutex::Release ( )

Definition at line 247 of file win32_misc.cpp.

247  {
248  ReleaseMutex( Handle() );
249 }
HANDLE Handle()
Definition: win32_misc.h:356

Field Documentation

HANDLE CMutex::m_hMutex
private

Definition at line 362 of file win32_misc.h.


The documentation for this class was generated from the following files: